Results 1 to 3 of 3

Thread: How to associate Icons w/ menu commands??

  1. #1

    Thread Starter
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    Anyone know how to display an icon to the left of a Menu command. I want to associate the same icons that are on my toolbar with the items on the actual pull-down menus.

    Thank GOD it's Friday......my brain is fried from this week!!!!!

  2. #2
    Guest
    Try this. Make a Form with a CommandButton and an ImageList and put the following code into it. Make sure you have an Image loaded in the ImageList.

    Code:
    Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
    Const MF_BITMAP = &H4&
    
    Private Sub Command1_Click()
    
        Dim hMenu As Long, hSub As Long, ItemID As Long
        hMenu = GetMenu(Me.hwnd)
        hSub = GetSubMenu(hMenu, 0)
        ItemID = GetMenuItemID(hSub, 0)
        SetMenuItemBitmaps hMenu, ItemID, MF_BITMAP, ImageList1.ListImages(1).Picture, ImageList1.ListImages(1).Picture
    
    End Sub

  3. #3
    Addicted Member
    Join Date
    May 1999
    Posts
    161

    Wink

    You can also check out the tutorial from Karl Moore...

    http://www.vb-world.net/api/winapi2/

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