DelphiFAQ Home Search:

How to add bitmaps to a menu?

 

commentsThis 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;

// ... in the FormCreate event:

// either load from an external file
Bmp1 := TPicture.Create;
Bmp1.LoadFromFile('c:\where\b1.BMP');
Bmp1Handle := Bmp1.Bitmap.Handle;
CheckedHandle := Bmp1Handle;

// or - using resources in the EXEcutable
Bmp1Handle := LoadBitmap (hInstance, 'RESOURCENAME');
CheckedHandle := LoadBitmap (hInstance, 'CHECKED_IMAGE');

// assign the bitmaps
SetMenuItemBitmaps(MenuItemTest.Handle, 0, MF_BYPOSITION,
                   Bmp1Handle, CheckedHandle);
...

Comments:

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.