VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Add bitmaps to your menu!

by [Mainframe] (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 20th April 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Add bitmaps to your menu!

API Declarations


' menu's. Then call the SetMenuBitmap sub to set a bitmap.
' hWnd: Give the HWND of the form wich contains the menu.
' menuIndex: Give the index of the menu, sample: the menu left is index 0, the
' one next to it is 1, and so on...
' SubmenuIndex: Index of the submenu, works the same way.
' Pic: Give the picture, use the LOADPICTURE function or specify a picturepox.picture.
' have any questions/comments? or want more of this, goto
' www.gangstersoft.com

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 Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As Long


Rate Add bitmaps to your menu!



Dim hMenu As Long
Dim hSubMenu As Long
Dim hID As Long

'Get the menuhandle of your app
hMenu& = GetMenu(hwnd)

'Get the handle of the first submenu (Hello)
hSubMenu& = GetSubMenu(hMenu&, menuIndex)

'Get the menuId of the first entry (Bitmap)
hID& = GetMenuItemID(hSubMenu&, SubmenuIndex)

'Add the bitmap

SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP, _
Pic, _
Pic


End Sub



Download this snippet    Add to My Saved Code

Add bitmaps to your menu! Comments

No comments have been posted about Add bitmaps to your menu!. Why not be the first to post a comment about Add bitmaps to your menu!.

Post your comment

Subject:
Message:
0/1000 characters