Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to add bitmaps to a menu item (2) Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
13-Sep-02
Category
VCL-Menu
Language
Delphi 2.x
Views
42
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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   var
2     Bmp1: TPicture;
3     CheckedHandle,
4       Bmp1Handle: THandle;
5   
6   // ... in the FormCreate event:
7   
8   // either load from an external file
9   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 EXEcutable
15  Bmp1Handle := LoadBitmap(hInstance, 'RESOURCENAME');
16  CheckedHandle := LoadBitmap(hInstance, 'CHECKED_IMAGE');
17  
18  // assign the bitmaps
19  SetMenuItemBitmaps(MenuItemTest.Handle, 0, MF_BYPOSITION,
20    Bmp1Handle, CheckedHandle);
21  ...


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC