Solved

Menu bar with images

Posted on 1998-06-23
3
230 Views
Last Modified: 2010-08-05
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.
0
Comment
Question by:jumpy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Expert Comment

by:Dalin
ID: 1464036
jumpy,
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) + " Pnt"
       '     '* 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(SubMenu(i%).Caption)
       Picture3(i%).Height = Picture3(i%).TextHeight(SubMenu(i%).Caption)
       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)) 'append this to previous line
       '     '* Replace bitmap for menu check mark with custom check
       '     '* bitmap
        x% = SetMenuItemBitmaps(hMenu%, menuId%, 0, 0, CLng(picture2.Picture))
Next i%

End Sub
0
 

Author Comment

by:jumpy
ID: 1464037
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 ?
0
 
LVL 9

Accepted Solution

by:
Dalin earned 200 total points
ID: 1464038
jumpy.
Download a sample at:
http://w1.2565.telia.com/~u256500520/
There are some others too.
Regards
Dalin
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question