VB给菜单加上图片

2018-06-17 17:12:50来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

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->

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:VB使用编程技巧三则

下一篇:VB经验谈:限制输入的文本框