CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Drop down Menu - icon

  1. #1
    Join Date
    Apr 2001

    Drop down Menu - icon

    Hi there,
    I want to add an icon/image against a menu item in the drop down menu list.Any suggestions. Thanks.

  2. #2
    Join Date
    May 2000
    New York, NY, USA

    Re: Drop down Menu - icon

    ' API stuff for putting bitmaps in menus.
    Private Type MENUITEMINFO
    cbSize As Long
    fMask As Long
    fType As Long
    fState As Long
    wid As Long
    hSubMenu As Long
    hbmpChecked As Long
    hbmpUnchecked As Long
    dwItemData As Long
    dwTypeData As Long
    cch As Long
    End Type

    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 SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal bypos As Long, lpcMenuItemInfo As MENUITEMINFO) As Long

    Private Const MF_BITMAP = &H4&
    Private Const MFT_BITMAP = MF_BITMAP
    Private Const MIIM_TYPE = &H10

    Private Sub Form_Load()
    Dim main_menu As Long
    Dim sub_menu As Long
    Dim menu_info As MENUITEMINFO
    Dim i As Integer

    main_menu = GetMenu(hwnd)
    sub_menu = GetSubMenu(main_menu, 0)
    For i = 0 To 2
    With menu_info
    .cbSize = Len(menu_info)
    .fMask = MIIM_TYPE
    .fType = MFT_BITMAP
    .dwTypeData = picFace(i).Picture
    End With
    SetMenuItemInfo sub_menu, i, True, menu_info
    Next i
    End Sub

    Iouri Boutchkine
    Iouri Boutchkine

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)