WEB开发网
开发学院WEB开发综合 VB给菜单加上图片 阅读

VB给菜单加上图片

 2006-02-27 11:53:42 来源:WEB开发网   
核心提示:PRivateDeclareFunctionGetMenuLib"user32"(ByValhwndAsLong)AsLongPrivateDeclareFunctionGetSubMenuLib"user32"(ByValhMenuAsLong,ByValnPosAsLong)
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->

Tags:VB 菜单 加上

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接