NO

Author Topic: Dialog, Menu, SHCreateMenuBar How dows it work?  (Read 5241 times)

KoenigDickBauch

  • Guest
Dialog, Menu, SHCreateMenuBar How dows it work?
« on: August 21, 2007, 06:00:21 PM »
Hi all,

how can i create a menu, this does not work, SHCreateMenuBar return NULL:

Code: [Select]
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpszCmdLine, int nCmdShow)
{
   .
   .
   .
   return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)MainDlgProc);
}


static LRESULT CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
        case WM_INITDIALOG:
        {
            SHINITDLGINFO shidi;

            /*
             * Create a Done button and size the dialog.
             */
            shidi.dwMask = SHIDIM_FLAGS;
            shidi.dwFlags = SHIDIF_DONEBUTTON|SHIDIF_SIPDOWN|SHIDIF_SIZEDLGFULLSCREEN;
            shidi.hDlg = hwndDlg;
            SHInitDialog(&shidi);


            SHMENUBARINFO mbi;
            memset(&mbi, 0, sizeof(SHMENUBARINFO));
            mbi.cbSize     = sizeof(SHMENUBARINFO);
            mbi.hwndParent = hwndDlg;
            mbi.nToolBarId =IDR_MENU ;
            mbi.hInstRes   =hInst;


            SHCreateMenuBar(&mbi)
    .
    .
    .

Is there any code snip?

KDB

KoenigDickBauch

  • Guest
Re: Dialog, Menu, SHCreateMenuBar How dows it work?
« Reply #1 on: August 21, 2007, 10:21:35 PM »
Hi,

if i make this

Code: [Select]
         SHMENUBARINFO mbi;
         memset(&mbi, 0, sizeof(SHMENUBARINFO));
         mbi.cbSize = sizeof(SHMENUBARINFO);
         mbi.dwFlags = SHCMBF_EMPTYBAR;   <<<<<<<<<<<<<
         mbi.nToolBarId = IDR_DLG_MENU;
         mbi.hInstRes = hInst;

         if (!SHCreateMenuBar(&mbi)){
             DWORD d = GetLastError();
             wchar_t lTmp[16];
             wsprintf(lTmp, L"Code: %d", d);
             MessageBox(NULL, lTmp, L"SHCreateMenuBar Failed", MB_TOPMOST);
         }
 

i get nor error, but an empty MenuBar.

If i put out the line with  SHCMBF_EMPTYBAR i get the error 120.

any idear?

KDB