Results 1 to 4 of 4

Thread: Perfect Code To Have Menu Icon

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Location
    Bangladesh
    Posts
    8

    Perfect Code To Have Menu Icon

    I NEED FULL CODE TO ADD AN ICON TO THE LEFT OF ANY MENU ITEM. ALSO SUGGEST HOW TO CREATE XP LIKE MENUS.

    THANKING, GOODBYE.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

  3. #3
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    The SetMenuItemBitmaps function should do it.

  4. #4
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    I lost my example, so here's an example from AllApi.
    VB Code:
    1. 'This project needs a form with a menu with at least one submenu
    2. 'It also needs a picturebox, Picture1, that contains a small b/w bitmap
    3. Const MF_BYPOSITION = &H400&
    4. Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
    5. Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    6. 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
    7. Private Sub Form_Load()
    8.     'KPD-Team 2000
    9.     'URL: [email][email protected][/email]
    10.     'E-Mail: [email][email protected][/email]
    11.     Dim hMenu As Long, hSubMenu As Long
    12.     'get the handle of the menu
    13.     hMenu = GetMenu(Me.hwnd)
    14.     'check if there's a menu
    15.     If hMenu = 0 Then
    16.         MsgBox "This form doesn't have a menu!"
    17.         Exit Sub
    18.     End If
    19.     'get the first submenu
    20.     hSubMenu = GetSubMenu(hMenu, 0)
    21.     'check if there's a submenu
    22.     If hSubMenu = 0 Then
    23.         MsgBox "This form doesn't have a submenu!"
    24.         Exit Sub
    25.     End If
    26.     'set the menu bitmap
    27.     SetMenuItemBitmaps hSubMenu, 0, MF_BYPOSITION, Picture1.Picture, Picture1.Picture
    28. End Sub

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