You know on programs like word, and excel you click File or hit alt+F and you will see next to new a little sheet of paper thingy, and next to open you see a folder. How do you put thos pics in?
Printable View
You know on programs like word, and excel you click File or hit alt+F and you will see next to new a little sheet of paper thingy, and next to open you see a folder. How do you put thos pics in?
Take a look at this example.
Still need more? Search www.planet-source-code.com for "Menu Icons".
This example supports only 13x13 bitmaps.Code:Public Declare Function GetMenu Lib "user32" _
(ByVal hwnd As Long) As Long
Public Declare Function GetSubMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPos As Long) As Long
Public Declare Function GetMenuItemID Lib "user32" _
(ByVal hMenu As Long, ByVal nPos As Long) As Long
Public 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
Function Pic_Menu(HdcPicC As Long, HdcPicUnC As Long)
Dim lngMenu As Long
Dim lngSubMenu As Long
Dim lngMenuItemID As Long
Dim lngRet As Long
lngMenu = GetMenu(Form1.hwnd)
lngSubMenu = GetSubMenu(lngMenu, 0)
lngMenuItemID = GetMenuItemID(lngSubMenu, 2)
lngRet = SetMenuItemBitmaps(lngMenu, lngMenuItemID, 0, _
Picture1.Picture, Picture1.Picture)
End Function
If you make menus with a couple of classes I've made, you can have menus that are exactly like the VB menus ;)
I'm e-mailing it to you now...
Code:Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private 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
Const MF_BITMAP = &H4&
Private Sub Command1_Click()
Dim hMenu As Long, hSub As Long, ItemID As Long
hMenu = GetMenu(Me.hwnd)
hSub = GetSubMenu(hMenu, 0)
ItemID = GetMenuItemID(hSub, 0)
SetMenuItemBitmaps hMenu, ItemID, MF_BITMAP, Picture1.Picture, Picture1.Picture
End Sub
Just a quick question about the code above .
When I use it my Icons seem to lose they're transparency .
I mean I have an icon with a transparent background , but
when it loads up into the menu it gets sort of discolored . How can I avoid that ?
[]P
I think you have to use 4 bit colors :(
Ouch!!!! ok thanks for the idea . Is there away around this ?
I'm sure there is (look at all the menus in some apps), but nobody seems to know