程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> VB給菜單加上圖片

VB給菜單加上圖片

編輯:VB綜合教程
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->

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved