PrivateDeclareFunctionGetMenuLib”user32″(ByValhwndAsLong)AsLong
PrivateDeclareFunctionGetSubMenuLib”user32″(ByValhMenuAsLong,ByValnPosAsLong)AsLong
PrivateDeclareFunctionGetMenuItemIDLib”user32″(ByValhMenuAsLong,ByValnPosAsLong)AsLong
PrivateDeclareFunctionSetMenuItemBitmapsLib”user32″_
(ByValhMenuAsLong,ByValnPositionAsLong,_
ByValwFlagsAsLong,ByValhBitmapUncheckedAsLong,_
ByValhBitmapCheckedAsLong)AsLong
PrivateConstMF_BITMAP=&H4&
PrivateTypeMENUITEMINFO
cbSizeAsLong
fMaskAsLong
fTypeAsLong
fStateAsLong
wIDAsLong
hSubMenuAsLong
hbmpCheckedAsLong
hbmpUncheckedAsLong
dwItemDataAsLong
dwTypeDataAsString
cchAsLong
EndType
PrivateDeclareFunctionGetMenuItemCountLib”user32″_
(ByValhMenuAsLong)AsLong
PrivateDeclareFunctionGetMenuItemInfoLib”user32″_
Alias”GetMenuItemInfoA”(ByValhMenuAsLong,_
ByValunAsLong,ByValbAsBoolean,_
lpMenuItemInfoAsMENUITEMINFO)AsBoolean
PrivateConstMIIM_ID=&H2
PrivateConstMIIM_TYPE=&H10
PrivateConstMFT_STRING=&H0&
PrivateSubcmdPicMenu_Click()
DimlngMenuHwndAsLong
DimlngSubHwndAsLong
DimlngMenuIDAsLong
//Retrievethemenuhandle
lngMenuHwnd=GetMenu(Me.hwnd)
//Getthehandleofthefirstsubmenuitem
lngSubHwnd=GetSubMenu(lngMenuHwnd,0)
//Getthemenuidofthefirstbitmpa
lngMenuID=GetMenuItemID(hSubMenu&,0)
//Addthebitmaptothemenuitem
SetMenuItemBitmapslngMenuHwnd,lngMenuID,MF_BITMAP,_
Picture1.Picture,_
Picture1.Picture
EndSub->