| View previous topic :: View next topic |
| Author |
Message |
Ian Hinson Member
Joined: 20 Jun 2004 Posts: 2 Location: Melbourne, Australia
|
Posted: 20/06/04 13:26 Post subject: System images for Toolbar buttons |
|
|
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.
It would be neat to have a TImageList that supplies this particular set of images.
Ian.
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 20/06/04 22:28 Post subject: |
|
|
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 |
|
 |
Ian Hinson Member
Joined: 20 Jun 2004 Posts: 2 Location: Melbourne, Australia
|
Posted: 21/06/04 13:57 Post subject: |
|
|
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 |
|
 |
|