Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 555
  • Last Modified:

Add an icon to a menu

May someone please explain how to add icons to menus?  Thank you in advance!
0
MatrixFreak
Asked:
MatrixFreak
1 Solution
 
MatrixFreakAuthor Commented:
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
 
Dang123Commented:
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
MoglorCommented:
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
 
MatrixFreakAuthor Commented:
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
 
MoglorCommented:
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
 
MatrixFreakAuthor Commented:
Thanks Moglor, i understood a lot more about menus.  I increased the points for the long wait!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now