• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

popup menu

how can i give a bitmap for the submenu items in a bit map
0
welakshmi
Asked:
welakshmi
1 Solution
 
welakshmiAuthor Commented:
easy question
0
 
MitchBroadheadCommented:
don't understand the question
0
 
vbWayneCommented:
'add a picture to a memu item
' Remarks:
' open a new app...add a picture box and a command button
' build a menu with menu editor
' add a bitmap pic to the picture box 13 x 13
' NOT an icon...a bitmap
' if you don't want to make bitmaps there is a freeware icon extractor
' at the site below which will save Icons as bitmaps
' therefore you can use the icon once you convert it to a bitmap

' http://www.ozemail.com.au/~jaesenj/software.html
'
' this will add the pic to your menu item
'
'
'<<<<<  put his code in a bas module  >>>>>>>>>
 
Public Declare Function GetSubMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPos As Long) As Long
Public Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long

Public 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



Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long

Public Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Boolean



Public Const MIIM_ID = &H2
Public Const MIIM_TYPE = &H10
Public Const MFT_STRING = &H0&
Public Const MF_BITMAP = &H4&

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 String
    cch As Long
End Type
'
' <<<<<<<< put this code in the event you wish to use  >>>>>>>>
'
'Get the menuhandle of your app
hMenu& = GetMenu(Form1.hwnd)

'Get the handle of the first submenu (Hello)
hSubMenu& = GetSubMenu(hMenu&, 0)

'Get the menuId of the first entry (Bitmap)
hID& = GetMenuItemID(hSubMenu&, 0)

'Add the bitmap
SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP, Picture1.Picture, Picture1.Picture

'You can add two bitmaps to a menuentry one for the checked and one for 'the unchecked state.
0
 
welakshmiAuthor Commented:
thank you for u'r answer,
but what u have given is exactly available at MSDN, this works well with the regular menu's but what i was asking for a popup menu, i will be happy if u can give me the answer to have a bitmap for submenu items in a popup menu.
0
 
xchaixCommented:
dear welaksmi,

you have to create a hidden menu.. if you have MDI.. create a menu with it submenu and hidden it..

then you can call a popup menu from command button or form by clicking mouse button or else..

add this code in your procedure

   PopupMenu mdiMain.mnuModule


-chai-
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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