Home   .......

Owner Drawn Menu Tutorial

Menu Properties

Products  
eXamples  
Files  
e-Mail Us  
 

 

So, now we are ready to start.

What we do is, get the handle of the main window menu (using GetMenu function), then get the handle of it's first submenu (using GetSubMenu, specifying we want to specify the menu by position, and using position 0 (first submenu)). Now we have the handle of File menu.

Now, in a loop, we get the ID of each menu item under File menu and:

- raise its MF_OWNERDRAW flag;
- set the item data to the number of the menu (each menu item has a 32-bit value specified by the application owning it, that may be used for whatever purposes the application needs - we will use this to identify which menu item to draw later).

Now all menu items under File menu are owner drawn. So, our window procedure (MyWndProc) will receive WM_MEASUREITEM and WM_DRAWITEM message for each 6 menu items (the separator bar is also considered a menu item)

 
Copyright (c) 1999, Billy&George Software and Peter Dimitrov
Revised May 1999