原帖及讨论:http://bbs.bccn.net/thread-113788-1-1.html 下面的这段代码将Picture1的图形作为菜单项。 首先建立一个模块,并加入下面的语句。 Declare Function GetMenu Lib "user32" _ (ByVal hwnd As Long) As Long Declare Function GetSubMenu Lib "user32" _ (ByVal hMenu As Long, ByVal nPos As Long) As Long Declare Function GetMenuItemID Lib "user32" _ (ByVal hMenu As Long, ByVal nPos As Long) As Long Declare Function SetMenuItemBitmaps Lib "user32" _ (ByVal hMenu As Long, ByVal nPosition As Long, _ ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, _ ByVal hBitmapChecked As Long) As Long Public Const MF_BITMAP = &H4& Type MENUITEMINFO cbSize As Long fMask As Long fType As Long fState As Long wID As Long hSubMenu As Long hbmpChecked As Long hbmpUnchecked As Long dwItemData As Long dwTypeData As String cch As Long End Type Declare Function GetMenuItemCount Lib "user32" _ (ByVal hMenu As Long) As Long Declare Function GetMenuItemInfo Lib "user32" _ Alias "GetMenuItemInfoA" (ByVal hMenu As Long, _ ByVal un As Long, ByVal b As Boolean, _ lpMenuItemInfo As MENUITEMINFO) As Boolean Public Const MIIM_ID = &H2 Public Const MIIM_TYPE = &H10 Public Const MFT_STRING = &H0&
form1中 ```
Private Sub Form1_load() ' 获得你的菜单的句柄 hMenu& = GetMenu(Form1.hwnd) ' 获得第一个子菜单的句柄 hSubMenu& = GetSubMenu(hMenu&, 0) ' 获得第一个菜单项 hID& = GetMenuItemID(hSubMenu&, 0) '加入位图 SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP, _ Picture1.Picture, _ Picture1.Picture End Sub 上面的代码使菜单项为图片,如果你只希望菜单项的左边有一个小位图,而右边仍为文字。可以先在Picture1绘制图片,在利用Picture1.Print加上文字,然后用Picture1.Picture加入菜单项。 点击下载该文件 <  
1/2 1 2 下一页 尾页 |