|
From: Matthias Heise on 22 Jun 2005 14:37 Hello, sorry for another new thread of mine. My app has a command bar with two pop-up menu entries. The first is called IDM_APPLICATION and the second IDM_NAVIGATION. To enable or gray a menu entry within the pop-up menu I need EnableMenuItem(hWndMenu, IDM_BACK, MF_ENABLED). The problem is how to get the hWndMenu (Type: HMENU) from the command bar. I tried TBBUTTONINFO tbbi; SendMessage(g_hwndCB, TB_GETBUTTONINFO, IDM_NAVIGATION, (LPARAM)&tbbi ); hWndMenu = (HMENU)tbbi.lParam; or hWndMenu = (HMENU) SendMessage( hWnd, SHCMBM_GETMENU, 0, 0 ); but both do not work correctly. When I use EnableMenuItem later it has no effekt. Is there any better way to do this? The menu is grayed in the beginning and when I connect my PDA to a remote device it should be enabled. Thanks Matthias
From: TJ on 22 Jun 2005 15:32 Use SHCreateMenuBar and member hwndMB of your SHMENUBARINFO struct will contain the handle. Here's an example: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceshellui5/html/wce50lrfSHCreateMenuBar.asp Matthias Heise wrote: > Hello, > > sorry for another new thread of mine. > > My app has a command bar with two pop-up menu entries. The first is called > IDM_APPLICATION and the second IDM_NAVIGATION. > > To enable or gray a menu entry within the pop-up menu I need > EnableMenuItem(hWndMenu, IDM_BACK, MF_ENABLED). > > The problem is how to get the hWndMenu (Type: HMENU) from the command bar. I > tried > > TBBUTTONINFO tbbi; > SendMessage(g_hwndCB, TB_GETBUTTONINFO, IDM_NAVIGATION, (LPARAM)&tbbi ); > hWndMenu = (HMENU)tbbi.lParam; > > or > > hWndMenu = (HMENU) SendMessage( hWnd, SHCMBM_GETMENU, 0, 0 ); > > but both do not work correctly. When I use EnableMenuItem later it has no > effekt. > > Is there any better way to do this? The menu is grayed in the beginning and > when I connect my PDA to a remote device it should be enabled. > > Thanks > > Matthias > >
From: Matthias Heise on 22 Jun 2005 15:54 The generated code (by eMbedded Visual Tools 3.0) uses SHCreateMenuBar but the hwndMB is a HWND type, not HMENU. That's my problem. Matthias
From: TJ on 22 Jun 2005 16:25 They all should work when casted. Are you checking if it is NULL or not? Matthias Heise wrote: > The generated code (by eMbedded Visual Tools 3.0) uses SHCreateMenuBar but > the hwndMB is a HWND type, not HMENU. That's my problem. > > Matthias > >
From: Frank Steinmetzger on 22 Jun 2005 19:36 Wed, 22 Jun 2005 20:37:56 +0200, Matthias Heise schrob: > Hello, > [...] > The problem is how to get the hWndMenu (Type: HMENU) from the command bar. I > tried > hWndMenu = (HMENU) SendMessage( hWnd, SHCMBM_GETMENU, 0, 0 ); > Matthias I once started a thread with the same question. After some discussion we came to this conclusion: // get the handle to the menu HMENU m=SHGetMenu(mbi.hwndMB); // and do something with it CheckMenuItem(m,IDM_ENABLED,MF_BYCOMMAND|MF_CHECKED); SHGetMenu is a macro which is defined as: #define SHGetMenu(hWndMB) (HMENU)SendMessage((hWndMB), \ SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0); Now I see you did the same SendMessage. But it looks to me as though you send it to the main window (hWnd), but you should send it to the handle which is assigned to the SHMENUBARINFO. My code: HWND CreateRpCommandBar(HWND hwnd) { SHMENUBARINFO mbi; memset(&mbi,0,sizeof(SHMENUBARINFO)); mbi.cbSize = sizeof(SHMENUBARINFO); mbi.hwndParent = hwnd; mbi.nToolBarId = IDM_MENU; mbi.hInstRes = g_hInst; mbi.nBmpId = 0; mbi.cBmpImages = 0; // I'm adding some bitmap buttons here // and finally: g_hMenu=(HMENU)SendMessage( mbi.hwndMB,SHCMBM_GETMENU, (WPARAM)0,(LPARAM)0); return mbi.hwndMB; } -- GruĂ˝ | Greetings | Qapla' "All I ask is a tall ship and a star to steer her by." http://www.stud.tu-ilmenau.de/~frst-ii/
|
Next
|
Last
Pages: 1 2 Prev: Sql Server CE 2.0 and Visual Studio 2005 Next: Linking for Imaging API's (reposted) |