DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   Watched TopicsWatched Topics     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

System images for Toolbar buttons

 
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> DELPHI AREA's Products
View previous topic :: View next topic  
Author Message
Ian Hinson
Member


Joined: 20 Jun 2004
Posts: 2
Location: Melbourne, Australia

PostPosted: 20/06/04 13:26    Post subject: System images for Toolbar buttons Reply with quote

Here's a tip many Delphi programmers may find useful:
How to get more "free" (and very useful) toolbar buttons from Windows.

1) Create a toolbar and add 15 or more buttons to it. Your form will look like this.



2) Add one line of code to the FormCreate event.

3) Run the program and the toolbar will look like this !!



The code that does this is:
procedure TForm1.FormCreate(Sender: TObject);
const
tbbitmap1: TTBAddBitmap = (hInst: HINST_COMMCTRL; nID: IDB_STD_SMALL_COLOR);
begin
SendMessage(ToolBar1.Handle, TB_ADDBITMAP, 15, integer(@tbbitmap1));
end;

All the icons that can be obtained using this technique are shown in the sample toolbar above because, each time you added a new toolbutton, Delphi incremented the ImageIndex automatically, and there are only 15 buttons in this CommCtrl set of icons.

The surprising thing is that the ImageIndex does matter (even though there is no TImageList on the form!)
Eg: If you put one button on the toolbar and set its ImageIndex to 7, then the OpenFile icon appears on it.

I'm writing this here because I initially thought these would be the images that TSysImageList provided.

Idea It would be neat to have a TImageList that supplies this particular set of images.

Ian.
Back to top
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 20/06/04 22:28    Post subject: Reply with quote

Thanks Ian for this nice trick.

I added a new property (IconSet) to TSysImageList for this purpose. The update is available to download.

Greetings,
Kambiz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ian Hinson
Member


Joined: 20 Jun 2004
Posts: 2
Location: Melbourne, Australia

PostPosted: 21/06/04 13:57    Post subject: Reply with quote

Your enhancement (v1.50) to incorporate this into TSysImageList is ingenius !
This is now definitely a component that every Delphi programmer MUST HAVE.

Thanks,
Ian.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> DELPHI AREA's Products All times are GMT
Page 1 of 1

Add to favorites

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group