How to create menu using vb6 with picture dropdown?

Asked By 40 points N/A Posted on -
qa-featured

Hi,

 I want to add picture to dropdown list of menu bar like we see a dropdown list with pictures when clicking on the file menu of MS Excel. Can I do this with my programme interface using vb6. Please help me to create menu using vb6 with picture dropdown.

SHARE
Best Answer by May Jratr
Answered By 0 points N/A #140550

How to create menu using vb6 with picture dropdown?

qa-featured

Hi Beatrice,

There are some ways where you can add an image to a specific menu using visual basic six. You can either use API or Picture Box to add an image to your menu. Three functions you can use from API are GetMenu, GetSubMenu & SetMenuTItemInfo. If you’re familiar with these, you can surely add your desired image on your menu. You may refer to the sample image. 

Best Answer
Best Answer
Answered By 0 points N/A #140551

How to create menu using vb6 with picture dropdown?

qa-featured

Hello  Beatricegvavra,

Hope that my message finds you well.
For building a menu with image in vb6 please do the following:
-Firstly go the menu editor from the menu bar.



-Or you can choose it from the tools menu.
-After the menu editor appears write the caption(The menu name)


-then click Ok

Then in the code add the following in Option Explicit:
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 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

 
  Then include the following in the form load:
  Private Sub Form_Load()
  Dim hMenu As Long
  Dim hSubMenu As Long
  Dim nPosition As Long
  Dim i As Long
  Dim x As Long
 
  hMenu = GetMenu(Me.hwnd)
  hSubMenu = GetSubMenu(hMenu, 0)
  For i = 0 To 2
    nPosition = GetMenuItemID(hSubMenu, i)
    x = SetMenuItemBitmaps(hMenu, nPosition, 0, CLng(Picture1(i).Picture), CLng(Picture1(i).Picture))
  Next
End Sub

Hope this solution will help you and please let me know if you need anything else.
Kind regards,

Related Questions