Author: William Gerbert
How to add bitmaps to a menu?
Answer:
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.
1 var2 Bmp1: TPicture;
3 CheckedHandle,
4 Bmp1Handle: THandle;
5 6 // ... in the FormCreate event:7 8 // either load from an external file9 Bmp1 := TPicture.Create;
10 Bmp1.LoadFromFile('c:\where\b1.BMP');
11 Bmp1Handle := Bmp1.Bitmap.Handle;
12 CheckedHandle := Bmp1Handle;
13 14 // or - using resources in the EXEcutable15 Bmp1Handle := LoadBitmap(hInstance, 'RESOURCENAME');
16 CheckedHandle := LoadBitmap(hInstance, 'CHECKED_IMAGE');
17 18 // assign the bitmaps19 SetMenuItemBitmaps(MenuItemTest.Handle, 0, MF_BYPOSITION,
20 Bmp1Handle, CheckedHandle);
21 ...