jumpy
asked on
Menu bar with images
How can I add an image to a menu Bar item (just like in WORD, Excel etc.)
I don't see any way doing it with the Menu Editor.
I don't see any way doing it with the Menu Editor.
ASKER
Running your function I get an error on this line:
SubMenu(i%).Caption = Picture3(i%).FontName +
Str$(Picture3(i%).FontSize ) + " Pnt"
After changing "SubMenu(i%)" to "hSubMenu(i%)" I get an error: "Expected Array".
Can you Please send a simple Working Example ?
SubMenu(i%).Caption = Picture3(i%).FontName +
Str$(Picture3(i%).FontSize
After changing "SubMenu(i%)" to "hSubMenu(i%)" I get an error: "Expected Array".
Can you Please send a simple Working Example ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this. Let me know if you have any questions
Regards
Dalin
'This code sample will change the actual menu bitmaps size,
' 'font size, color, and caption. Run the application and 'sel
' ect the BitMenu and view the selections. Then click 'the for
' m and revisit the BitMenu. '-------------------------
' ------------------------- Sub Command2_Click ()
' '* Example to create a dynamic menu system
hMenu% = GetMenu(hWnd)
hSubMenu% = GetSubMenu(hMenu%, 0)
For i% = 0 To Number_of_Menu_Selections - 1
' '* Place some text into the menu.
SubMenu(i%).Caption = Picture3(i%).FontName +
Str$(Picture3(i%).FontSize
' '* 1. Must be AutoRedraw for Image().
' '* 2. Set Backcolor of Picture control to that of the
' '*current system Menu Bar color, so Dynamic bitmaps
' '*will appear as normal menu items when menu bar
' '*color is changed via the control panel
' '* 3. See the bitmaps on screen, this could all be done
' '*at design time.
Picture3(i%).AutoRedraw = TRUE
Picture3(i%).BackColor = CLR_MENUBAR
' '* You can uncomment this
' '* Picture3(i%).Visible = FALSE
' '* Set the width and height of the Picture controls
' '* based on their corresponding Menu items caption,
' '* and the Picture controls Font and FontSize.
' '* DoEvents() is necessary to make new dimension
' '* values to take affect prior to exiting this Sub.
Picture3(i%).Width = Picture3(i%).TextWidth(Sub
Picture3(i%).Height = Picture3(i%).TextHeight(Su
Picture3(i%).Print SubMenu(i%).Caption
' '* - Set picture controls backgroup picture (Bitmap) to
' '*its Image.
Picture3(i%).Picture = Picture3(i%).Image
x% = DoEvents()
Next i%
' '* Get handle to forms menu.
hMenu% = GetMenu(Form1.hWnd)
' '* Get handle to the specific menu in top level menu.
hSubMenu% = GetSubMenu(hMenu%, 0)
For i% = 0 To Number_of_Menu_Selections - 1
' '* Get ID of sub menu
menuId% = GetMenuItemID(hSubMenu%, i%)
' '* Replace menu text w/bitmap from corresponding picture
' '* control
x% = ModifyMenu(hMenu%, menuId%, MF_BITMAP, menuId%,
CLng(Picture3(i%).Picture)
' '* Replace bitmap for menu check mark with custom check
' '* bitmap
x% = SetMenuItemBitmaps(hMenu%,
Next i%
End Sub