Home   .......

Owner Drawn Menu Tutorial

Code: Menu Properties

Products  
eXamples  
Files  
e-Mail Us  
 

 

We'll focus on the source executed under Command1_Click event and in MyWndProc procedure. Let's start with Command1_Click:

Dim MainMenu As Long, FileMenu As Long
Dim x As Long, y As Long
MainMenu = GetMenu(Me.Hwnd)
FileMenu = GetSubMenu(MainMenu, 0)

So, we declare some variables and retrieve the handle of the main menu. Then, using GetSubmenu, we retrieve the handle of the first submenu.

For x = 0 To 5
y = GetMenuItemID(FileMenu, x)
ModifyMenu FileMenu, x, MF_BYPOSITION Or MF_OWNERDRAW, y, x
Next x

Get the menu ID (it is required by ModifyMenu, otherwise we don't need it), set MF_OWNERDRAW flag and specify the application defined 32-bit value to the corresponding number for each menu item.

DispStatus "Own Menu Created"
Command1.Enabled = True

Display message and disable Command1

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