Scalabium Software

SMExport/SMImport suites
Knowledge for your independence'.
Home Delphi and C++Builder tips


#33: How can I add the bitmaps to menu items?

From Delphi 4 you can add the bitmaps to your menu items.
But in Delphi 2/3 you haven't such useful possibility.

I use the next method:
1. you must declare a TBitmap variable:
var bmp: TBitmap

2. load the bitmap (from file, resource etc):
bmp.LoadFromFile('c:\yourPath\...\copy.bmp');

In default MS Windows settings the glyphs in menu have a 12x12pixels. If your bitmap have other size, then this bitmap will stretched.

3. set bitmap to menu item:
SetMenuItemBitmaps(yourMenu.Handle, intIndex, MF_BYPOSITION, bmp.Handle, bmp.Handle),
where:
- yourMenu is a menu component (TMainMenu or TPopupMenu)
- intIndex is a menu item position (from 0)
- first bmp.Handle is a handle of bitmap for unchecked state
- second bmp.Handle is a handle of bitmap for checked state

Of course, you can set the same bmp.Handle or set the different bitmaps for unchecked/checked states

PS: some days ago the one registered user ask me: "why in your SMReport Designer you not use a glyphs in menu?". I forgot it! Of course, yesterday I included such feature in few minutes and "SMReport use the bitmaps in menu and is MS Office compatible now...":))


Published: October 21, 1999

See also
 
Fast Document Viewer
Paradox Password Recovery
ExcelFile Viewer
Excel Web-stream
DBISAM Password Recovery
Metafile Convert
Clarion Viewer
Excel Reader (dll)
SMDBGrid
Paradox Viewer
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2017, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMReport Autogenerated