Solved

Add an icon to a menu

Posted on 2003-12-11
7
549 Views
Last Modified: 2010-05-01
May someone please explain how to add icons to menus?  Thank you in advance!
0
Comment
Question by:MatrixFreak
7 Comments
 
LVL 13

Expert Comment

by:crazyman
ID: 9921401
0
 
LVL 1

Author Comment

by:MatrixFreak
ID: 9921797
crazyman, is it possible to add an icon to the normal menu that comes with VB using the Windows API?  If possible, is it too complicated to do?  I've used some of the Windows API but i don't have a full understanding of all the options available.  It'll be a few hours or days (Friday, or Monday) for my next reply.  Rest assured someone will get the points!
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9922069
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 1

Expert Comment

by:Moglor
ID: 9922838
you need a picturebox with a 14x14 picture in it and a menu item with at least one sub menu item.

Const MF_BYPOSITION = &H400&
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 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
Private Sub Form_Load()
    Dim hMenu As Long, hSubMenu As Long
    'get the handle of the menu
    hMenu = GetMenu(Me.hwnd)
    'check if there's a menu
    If hMenu = 0 Then
        MsgBox "This form doesn't have a menu!"
        Exit Sub
    End If
    'get the first submenu
    hSubMenu = GetSubMenu(hMenu, 0)
    'check if there's a submenu
    If hSubMenu = 0 Then
        MsgBox "This form doesn't have a submenu!"
        Exit Sub
    End If
    'set the menu bitmap
    SetMenuItemBitmaps hSubMenu, 0, MF_BYPOSITION, Picture1.Picture, Picture1.Picture
End Sub
0
 
LVL 1

Author Comment

by:MatrixFreak
ID: 9942385
Moglor, i got your code to work, but is there any way to have it display pictures that are larger than 14x14 in dimension?  The notification area menu from ATI provides the option to choose between small and large icons.  I was hoping for an image larger than 14x14.
0
 
LVL 1

Accepted Solution

by:
Moglor earned 300 total points
ID: 9948673
i did some looking around and found this article on how to add bitmaps to menus

http://www.elitevb.com/content/01,0009,01/

hope that helps
0
 
LVL 1

Author Comment

by:MatrixFreak
ID: 10073862
Thanks Moglor, i understood a lot more about menus.  I increased the points for the long wait!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

786 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