Results 1 to 3 of 3

Thread: VB Snippet - Bitmap in Menus

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    VB Snippet - Bitmap in Menus

    Add a picturebox with a 16x16 bitmap

    VB Code:
    1. Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
    2.  
    3. Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    4.  
    5. 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
    6.  
    7. Const MF_BYPOSITION = &H400&
    8.  
    9. Private Sub Form_Load()
    10.  
    11.     Dim hMenu As Long, hSubMenu As Long
    12.  
    13.     ' GET HWND OF MENU
    14.  
    15.     hMenu = GetMenu(Me.hwnd)
    16.  
    17.     ' ENSURE EXISTANCE OF MENU
    18.  
    19.     If hMenu = 0 Then
    20.  
    21.         MsgBox "This form doesn't have a menu!"
    22.  
    23.         Exit Sub
    24.  
    25.     End If
    26.  
    27.     ' FIND 1ST SUB-MENU
    28.  
    29.     hSubMenu = GetSubMenu(hMenu, 0)
    30.  
    31.     ' ENSURE EXISTANCE OF SUB - MENU
    32.  
    33.     If hSubMenu = 0 Then
    34.  
    35.         MsgBox "This form doesn't have a submenu!"
    36.  
    37.         Exit Sub
    38.  
    39.     End If
    40.  
    41.     ' SET THE MENU BITMAP
    42.  
    43.     SetMenuItemBitmaps hSubMenu, 0, MF_BYPOSITION, _
    44. Picture1.Picture, Picture1.Picture
    45.  
    46. End Sub
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  2. #2
    Hyperactive Member csar's Avatar
    Join Date
    Mar 2002
    Location
    Siam
    Posts
    288

    Question

    The size is smaller than 16x16..(I guess it equal checkbox size?!?) Have another way to put picture into menu bar?
    Don't leave it till tomorrow, Do It Now!
    5361726176757468204368616E63686F747361746869656E

  3. #3
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    You could use a XP Style Menu found at vbSmart

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width