Solved

Showing only one image in a TSpeedButton

Posted on 2001-09-15
9
545 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now