Scalabium Software

SMExport advertising
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):

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),
- 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
Viewer for MS Outlook Messages
Clarion to Text converter
dBase Viewer
Paradox ActiveX
ABA Database Convert
Mail parser (ActiveX)
ABA Picture Convert
Protected Storage Viewer

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2018, Scalabium Software. All rights reserved.

SMExport advertising