首页 > 学院 > 开发设计 > 正文

VB给菜单加上图片

2019-11-18 17:39:24
字体:
来源:转载
供稿:网友
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->


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表