Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
How to add bitmaps to a menu?
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Create a Picture. Load a .BMP from somewhere into the picture.
Better have the picture as a resource and load the handle with LoadBitmap().
Use the SetMenuItemBitmaps API call to connect the Picture to the Menu.
All this can by coded in the .Create of a form.
Don't use a bitmap that is too large :) because only the right-top
of the bitmap is displayed.
 | |  | |
var
Bmp1 : TPicture;
CheckedHandle,
Bmp1Handle : THandle;
Bmp1 := TPicture.Create;
Bmp1.LoadFromFile('c:\where\b1.BMP');
Bmp1Handle := Bmp1.Bitmap.Handle;
CheckedHandle := Bmp1Handle;
Bmp1Handle := LoadBitmap (hInstance, 'RESOURCENAME');
CheckedHandle := LoadBitmap (hInstance, 'CHECKED_IMAGE');
SetMenuItemBitmaps(MenuItemTest.Handle, 0, MF_BYPOSITION,
Bmp1Handle, CheckedHandle);
...
| |  | |  |
Comments:
|