Solved

Showing only one image in a TSpeedButton

Posted on 2001-09-15
9
553 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:jdthedj
9 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6484439
adjust the numglyphs property to the count of images of your bitmap
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 6484442
set NumGlyphs to 4, I guess
0
 
LVL 3

Expert Comment

by:marcoszorrilla
ID: 6484445
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;
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 3

Author Comment

by:jdthedj
ID: 6485074
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
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6485082
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 ;-)

0
 
LVL 3

Author Comment

by:jdthedj
ID: 6485330
Thanks Meikl

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

John
0
 
LVL 1

Accepted Solution

by:
Fraction earned 20 total points
ID: 6485773
Suppose the glyphs width and height are the same, then you might do something like this:

NumGlyph := round(Bitmap.Width / Bitmap.Height);
0
 
LVL 3

Author Comment

by:jdthedj
ID: 6491729
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
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6492527
i guessed you more clever, my mistake
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question