I have a MDI FORM, i have added a menu in it, now i want to add the pictures in that menu, but it is not displaying the pictures, while that same code i have tried on normal form, it works superb.but not working with MDI.

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
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 1
    nPosition = GetMenuItemID(hSubMenu, i)
    x = SetMenuItemBitmaps(hMenu, nPosition, 0, CLng(Picture1(i).Picture), CLng(Picture1(i).Picture))
  Next
End Sub

i have put 2 pictures boxes to add images in popup menu, same code works fine with normal form, but doesnt display pictures in MDI FORM's Menu.

Recommended Answers

All 2 Replies

well your code its working to me.

this code is not working on MDI form...i have menus on mdi form, it is not displaying pictures in menu, which i have kept on mdi form./

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.