Good day.!

I have created a menu editor with a name File. This file menu contains a popup menu which is(back-up database,restore database,logout). With this popup, i want to add an icon on the left sides all of them. Does any one there can help me pls.
this is how i show my pop up menu because ive disable it in menu editor creation.

popupmenu file

Thank you. God bless on this mother earth.!

Pls help.!!

Add a menu item and a sub-menu to the main menu to the form.
Add a picture box to the form and set its visible property to False.

Add the following code to a general module (.BAS).(API Functions)
=================================================

Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Public Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public 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
Public Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long

Add this code to the form load event.
==============================

Picture1.Picture = LoadPicture(app.path & "\" & "CUT.BMP")
Dim D As Long, DU as Long
Dim H As Long
D = CreateCompatibleDC(Picture1.hdc)
H = CreateCompatibleBitmap(Picture1.hdc, 16, 16)

Dim P As Long
P = SelectObject(D, H)
DU = BitBlt(D, 0, 0, 16, 16, Picture1.hdc, 0, 0, &HCC0020)
DU = SelectObject(D, P)
D = ModifyMenu(GetSubMenu(GetMenu(Me.hwnd), 0), 0, &H404, 0, H)

Add a menu item and a sub-menu to the main menu to the form.
Add a picture box to the form and set its visible property to False.

Add the following code to a general module (.BAS).(API Functions)
=================================================

Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Public Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public 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
Public Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long

Add this code to the form load event.
==============================

Picture1.Picture = LoadPicture(app.path & "\" & "CUT.BMP")
Dim D As Long, DU as Long
Dim H As Long
D = CreateCompatibleDC(Picture1.hdc)
H = CreateCompatibleBitmap(Picture1.hdc, 16, 16)

Dim P As Long
P = SelectObject(D, H)
DU = BitBlt(D, 0, 0, 16, 16, Picture1.hdc, 0, 0, &HCC0020)
DU = SelectObject(D, P)
D = ModifyMenu(GetSubMenu(GetMenu(Me.hwnd), 0), 0, &H404, 0, H)

Good day sir.!

Thank you for a nice reply.! Below is the code ive modified. Can i use .ICO extension instead of bmp.Below is the code ive modified but it fails to load the icon on the sub menu. pls help

Picture1.Picture = LoadPicture(App.Path & "\icons\" & "Database-Edit.ICO")
Dim D As Long, DU As Long
Dim H As Long
D = CreateCompatibleDC(Picture1.hdc)
H = CreateCompatibleBitmap(Picture1.hdc, 16, 16)
 
Dim P As Long
P = SelectObject(D, H)
DU = BitBlt(D, 0, 0, 16, 16, Picture1.hdc, 0, 0, &HCC0020)
DU = SelectObject(D, P)
D = ModifyMenu(GetSubMenu(GetMenu(Me.hwnd), 0), 0, &H404, 0, H)
This article has been dead for over six months. Start a new discussion instead.