Solved

Add an icon to a menu

Posted on 2003-12-11
7
553 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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 …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

623 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