Solved

Add an icon to a menu

Posted on 2003-12-11
7
547 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now