Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Add an icon to a menu

Posted on 2003-12-11
7
Medium Priority
?
554 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
[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
7 Comments
 
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
Technology Partners: 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!

 
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 1200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses

722 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