Results 1 to 3 of 3

Thread: Modify Top Level Menu

  1. #1
    NewPeter
    Guest

    Question Modify Top Level Menu

    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

  2. #2
    Member choochoo's Avatar
    Join Date
    Jun 2001
    Posts
    51
    the second "level"? more specific?

    menu menu
    submenuitem0 submenuitem0
    submenuitem1
    submenuitem
    submenuitem

    ?
    what are you referring to?

  3. #3
    NewPeter
    Guest
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width