#### Archived

This topic is now archived and is closed to further replies.

## Recommended Posts

Why doesn´t this work?
  .... AddBitmapToMenuItem(IDR_MENU1, ID_FILE_EXIT, IDB_BITMAP5); ... bool CWndMain::AddBitmapToMenuItem(int p_iResourceIdMenu, int p_iResourceIdMenuItem, int p_iResourceIdIcon) { HINSTANCE l_hInstance = (HINSTANCE) GetWindowLong(m_hWnd, GWL_HINSTANCE); HBITMAP l_hBitmap = LoadBitmap(l_hInstance, MAKEINTRESOURCE(p_iResourceIdIcon)); HMENU l_hMenu = LoadMenu(l_hInstance, MAKEINTRESOURCE(IDR_MENU1)); if(SetMenuItemBitmaps(l_hMenu,p_iResourceIdMenuItem,MF_BYCOMMAND,l_hBitmap,l_hBitmap) == 0) return false; return true; } 
It works if I replace
  HMENU l_hMenu = LoadMenu(l_hInstance, MAKEINTRESOURCE(IDR_MENU1)); 
with
  HMENU l_hMenu = GetMenu(m_hWnd); 

##### Share on other sites
Brannon    122

after it, does it work? The thing is, calling LoadMenu(), will load it.. but you have to actually do something with it afterwards. GetMenu() gets the active menu for the window, which in this case I think is what you want.. right?

-Brannon

##### Share on other sites

I´m in school right now so I can´t test SetMenu right now but I will do that when I come home.

The thing is that I want to use this function for all kinds of menus not just for the main window. For instance I will use it for a popup menu for a toolbar button.

##### Share on other sites
Brannon    122
So you basically want to do the following?

-Brannon