Article View: borland.public.delphi.vcl.components.using.general
Article #263Re: TImageList/TSpeedbutton question
From: Peter Below (TeamB)
Date: Mon, 04 Aug 2008 08:31
Date: Mon, 04 Aug 2008 08:31
48 lines
3490 bytes
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
Technical Details
Message-ID:
<xn0ftixp82cqe1001@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!news.osn.de!diablo2.news.osn.de!ecngs!feeder.ecngs.de!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<48964120$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 16f96a,4008fd9eb5cfedf1 X-Google-Attributes: gid16f96a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Peter Below (TeamB)" <none@nomail.please> Subject: Re: TImageList/TSpeedbutton question Newsgroups: borland.public.delphi.vcl.components.using.general References: <48964120$1@newsgroups.borland.com> User-Agent: XanaNews/1.18.1.6 Message-ID: <xn0ftixp82cqe1001@newsgroups.borland.com> X-Ref: newsgroups.borland.com ~XNS:000014D5 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 NNTP-Posting-Host: 93.129.10.70 Date: 4 Aug 2008 01:31:25 -0700 X-Trace: newsgroups.borland.com 1217838685 93.129.10.70 (4 Aug 2008 01:31:25 -0700) Lines: 48 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!news.osn.de!diablo2.news.osn.de!ecngs!feeder.ecngs.de!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail