Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Place Icons on menu items in a form?

API Functions

How to Place Icons on menu items in a form?

by  wgcs  Posted    (Edited  )
Thanks to Adolfo Huaman Capani for making this method clear. You can get his complete example from the www.UniversalThread.com by searching for "
Icons in menu for any VFP version" or for the file menubitm.zip

The significant method is below:
Code:
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
*/*/*Desarrollado por Dofo
*/*/*		HCdofo@hotmail.com
*/*/*		HCdofo@yahoo.es
*/*/*		Huancayo - Peru
*/*/*		Adolfo Huaman Capani
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
LOCAL HWND, HMenu, HSubMenu, MenuBarID, lcImage, lbImage

****
* Get a handle on the Window and it's menu:
DECLARE INTEGER FindWindow    IN win32api STRING,STRING
DECLARE INTEGER GetMenu       IN win32api INTEGER
DECLARE INTEGER GetSubMenu    IN win32api INTEGER,INTEGER
DECLARE INTEGER GetMenuItemID IN win32api INTEGER,INTEGER

HWnd      = findwindow( 0, THISFORM.Caption )
HMenu     = getmenu( m.HWND )
HSubMenu  = getsubmenu( m.mhandle, 0 )  && First submenu
MenuBarID = getmenuitemid( m.HSubMenu, 0 ) && First menu item

****
* Load the Bitmap so we can use it
DECLARE INTEGER LoadImage IN win32api INTEGER, STRING, INTEGER, INTEGER, INTEGER, INTEGER

lcImage  = Set("DEFAULT")+CURDIR()+"Bitmap.Bmp"
lbImage  = Loadimage( 0, m.lcImage, 0, 13, 13, 32768+16+2 )

****
* Make adjustments to the menu
DECLARE INTEGER SetMenuItemBitmaps IN win32api INTEGER, INTEGER, INTEGER, INTEGER, INTEGER
DECLARE INTEGER ModifyMenu IN win32api INTEGER, INTEGER, INTEGER, INTEGER, STRING

setmenuitembitmaps( m.HSubMenu, m.MenuBarID, 0, m.lbImage, m.lbImage )

* Set the caption on the menu item, too:
modifymenu( m.HSubMenu, m.MenuBarID, 0, m.MenuBarID, "&Nuevo	F2" )
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top