Link to home
Start Free TrialLog in
Avatar of APS NZ
APS NZFlag for New Zealand

asked on

Showing only one image in a TSpeedButton

Hi

When I load a glyph into a TSpeedButton at runtime, and it contains more than one image, it wants to display them all at the same time.  How do I get the button to display only the first image?

John
Avatar of kretzschmar
kretzschmar
Flag of Germany image

adjust the numglyphs property to the count of images of your bitmap
Avatar of TOndrej
TOndrej

set NumGlyphs to 4, I guess
Perhaps with this code?

These lines of code load a four-image bitmap into the Glyph property of a speed button, and specify the appropriate value for the NumGlyphs property:

SpeedButton1.Glyph.LoadFromFile('MYBITMAP.BMP');

SpeedButton1.NumGlyphs := 4;
Avatar of APS NZ

ASKER

Thanks for the replies.

I have tried using the NumGlyphs property, but I still find that the speedbutton tries to load all the images at once.  This is my code:

GlyphBtn[UpTo].NumGlyphs := 1;
GlyphBtn[UpTo].Glyph.LoadFromFile(DirInfo.Name);

(I am using FindFirst etc to locate the bitmaps). I also tried setting NumGlyphs after loading the image, but I still get the same result.  Any ideas?

John
to repeat

>adjust the numglyphs property to the count of images of your bitmap

contains your bitmap 4 pictures then set NumGlyphs to 4 -> one image is shown on the speedbutton
contains your bitmap 2 pictures then set NumGlyphs to 2 -> one image is shown on the speedbutton

meikl ;-)

Avatar of APS NZ

ASKER

Thanks Meikl

How do I know how many images there are in the bitmap?

John
ASKER CERTIFIED SOLUTION
Avatar of Fraction
Fraction

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of APS NZ

ASKER

Hello Fraction

I never realised it would be so complicated!  You gave me the right idea.  I divided the width by 24 (an average size) and used the integer result as the answer.  It seem to work OK.  I am surprised there is not a property called ImageCount or something.

John
i guessed you more clever, my mistake