🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.vcl.components.using.general
3 messages
3 total messages Started by John B Sun, 03 Aug 2008 23:37
TImageList/TSpeedbutton question
#262
Author: John B
Date: Sun, 03 Aug 2008 23:37
9 lines
1392 bytes
As I understand it, TSpeedButton can accept images with multiple glyphs 
(eg., 1x1, 1x2, 1x3, or 1x4) to represent the different states of the 
TSpeedButton.  It can also use a TImageList and a reference to display 
glyphs.  Is there a way to use a TImageList or some other similar component 
with different sized images to take advantage of this feature?

Thanks,

John 
Re: TImageList/TSpeedbutton question
#263
Author: Peter Below (TeamB)
Date: Mon, 04 Aug 2008 08:31
48 lines
3490 bytes
John B wrote:

> As I understand it, TSpeedButton can accept images with multiple
> glyphs (eg., 1x1, 1x2, 1x3, or 1x4) to represent the different states
> of the TSpeedButton.  It can also use a TImageList and a reference to
> display glyphs.  Is there a way to use a TImageList or some other
> similar component with different sized images to take advantage of
> this feature?

A TSpeedbutton cannot use an image list *directly*. It can be tied to
an imagelist through an action, though. With a bit of fiddling you can
get it to use "multiple glyph" images from an imagelist. This can be
done the following way:

Drop a TImagelist on the form and set it Height to 16 and the Width to
32. Doubleclick on it and use the imagelist editor to add some of the
button glyphs from the images that come with Delphi to the list. Note
that these bitmaps need to be 16*32, you cannot load two 16*16 images
and get the imagelist to treat them as one image. Assign this imagelist
to a TActionlist, add a few actions, set the actions ImageIndex as
needed, drop a couple of speedbuttons or bitbuttons, assign the actions
to each and then set the NumGlyphs property of the buttons to 2. That
is the step not done automatically. The result works as intended
because the buttons make an internal copy of the imagelist image into
their Glyph property (inefficient and wasteful of resources, but that
was the easiest way to implement it in a way that also allows the
buttons to be used without associated actions).

If you want to start with two 16*16 images your best bet is to create
another imagelist (16*16 this time) and load the images into it in the
correct sequence. Then use code to create 16*32 images from those at
run-time and deposit them into a new imagelist set to 16*32 size, then
tie that to the actionlist and set the NumGlyphs properties as
required, also in code. Same applies to 16*48 or 16*64 images, of
course, but you have to decide on one format to use, since a given
imagelist can only hold images that are all of the same size, and an
actionlist can only be tied to one imagelist. Supporting a mixture of
sizes would be a bit cumbersome since you would need a separate
actionlist + imagelist for every image size you want to use.



-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
Re: TImageList/TSpeedbutton question
#264
Author: John B
Date: Tue, 05 Aug 2008 00:20
75 lines
4968 bytes
Thanks Peter!  I am indeed using a TActionList to load the TSpeedButtons.

What prompted my question was an apparent difference in the way D6 behaved 
vs D2007.  Based on your response, I think I discovered what happened.

When I initially loaded the TImageList, I mixed 16x16 and 16x32 images, 
which actually cropped the longer ones to 16x16.  I then assigned the 
TImageList to a TActionList, and assigned image references to each of the 
actions.

However, in my programming a long time ago, I'm sure I must have reloaded 
the 16x32 Glyphs into several TSpeedbuttons (setting NumGlyphs to 2) to get 
them to behave properly, which I am sure overrides the TAction glyph.

When I recompiled in D2007, the images weren't displaying properly in the 
IDE, so I reset all the TAction links in the TSpeedButtons.  This reset the 
TSpeedButton glyphs, making the ones set for 2 glyphs to show only half the 
image.

Thanks again for your help.  I now have two choices:
1) Override the 2-glyph speedbuttons again
2) Create 16x32 glyphs for all the current 16x16 images

John

"Peter Below (TeamB)" <none@nomail.please> wrote in message 
news:xn0ftixp82cqe1001@newsgroups.borland.com...
> John B wrote:
>
>> As I understand it, TSpeedButton can accept images with multiple
>> glyphs (eg., 1x1, 1x2, 1x3, or 1x4) to represent the different states
>> of the TSpeedButton.  It can also use a TImageList and a reference to
>> display glyphs.  Is there a way to use a TImageList or some other
>> similar component with different sized images to take advantage of
>> this feature?
>
> A TSpeedbutton cannot use an image list *directly*. It can be tied to
> an imagelist through an action, though. With a bit of fiddling you can
> get it to use "multiple glyph" images from an imagelist. This can be
> done the following way:
>
> Drop a TImagelist on the form and set it Height to 16 and the Width to
> 32. Doubleclick on it and use the imagelist editor to add some of the
> button glyphs from the images that come with Delphi to the list. Note
> that these bitmaps need to be 16*32, you cannot load two 16*16 images
> and get the imagelist to treat them as one image. Assign this imagelist
> to a TActionlist, add a few actions, set the actions ImageIndex as
> needed, drop a couple of speedbuttons or bitbuttons, assign the actions
> to each and then set the NumGlyphs property of the buttons to 2. That
> is the step not done automatically. The result works as intended
> because the buttons make an internal copy of the imagelist image into
> their Glyph property (inefficient and wasteful of resources, but that
> was the easiest way to implement it in a way that also allows the
> buttons to be used without associated actions).
>
> If you want to start with two 16*16 images your best bet is to create
> another imagelist (16*16 this time) and load the images into it in the
> correct sequence. Then use code to create 16*32 images from those at
> run-time and deposit them into a new imagelist set to 16*32 size, then
> tie that to the actionlist and set the NumGlyphs properties as
> required, also in code. Same applies to 16*48 or 16*64 images, of
> course, but you have to decide on one format to use, since a given
> imagelist can only hold images that are all of the same size, and an
> actionlist can only be tied to one imagelist. Supporting a mixture of
> sizes would be a bit cumbersome since you would need a separate
> actionlist + imagelist for every image size you want to use.
>
>
>
> -- 
> Peter Below (TeamB)
> Don't be a vampire (http://slash7.com/pages/vampires),
> use the newsgroup archives :
> http://www.tamaracka.com/search.htm
> http://groups.google.com 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads