PDA

Click to See Complete Forum and Search --> : Modify Top Level Menu


NewPeter
Jan 17th, 2002, 10:12 PM
Hi everybody
I had use the code below to modif menu but it can modify only the 2nd level or lower. I want to modify the Top level menu. please give some example and code.

Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
Const MF_BITMAP = 4
Const MF_CHECKED = 8
Private Sub Form_Load()
Dim hMenu As Long, hSubMenu As Long, lngID As Long
'Get the handle of the form's menu
hMenu = GetMenu(Me.hWnd)
'Get the handle of the form's submenu
hSubMenu = GetSubMenu(hMenu, 0)

'Change first item (index=0)
picBitmaps(0).Picture = picBitmaps(0).Image
lngID = GetMenuItemID(hSubMenu, 0)
Call ModifyMenu(hMenu, lngID, MF_BITMAP, lngID, CLng(picBitmaps(0).Picture))

'Change second item (index=1)
picBitmaps(1).Picture = picBitmaps(1).Image
lngID = GetMenuItemID(hSubMenu, 1)
Call ModifyMenu(hMenu, lngID, MF_BITMAP, lngID, CLng(picBitmaps(1).Picture))

'Change third item (index=2)
picBitmaps(2).Picture = picBitmaps(2).Image
lngID = GetMenuItemID(hSubMenu, 2)
Call ModifyMenu(hMenu, lngID, MF_BITMAP, lngID, CLng(picBitmaps(2).Picture))

mnuBitmap1.Checked = True
End Sub
Private Sub mnuBitmap1_Click()
mnuBitmap1.Checked = Not mnuBitmap1.Checked
End Sub
Private Sub mnuBitmapEnd_Click()
End
End Sub

choochoo
Jan 23rd, 2002, 12:07 PM
the second "level"? more specific?

menu menu
submenuitem0 submenuitem0
submenuitem1
submenuitem
submenuitem

?
what are you referring to?

NewPeter
Jan 24th, 2002, 09:49 PM
I want to Modify the top level menu but I don't know what function I should use. I'd tried to use the code about to modify the top level menu but it can't. It can only modify the 2nd level menu ( when you click on the top level menu then it appear ). If somebody know how to modify the top level menu please give some example and code.