Solved

Showing only one image in a TSpeedButton

Posted on 2001-09-15
9
556 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Path  to current project in Delphi. 2 92
Correct Component for Shopping Cart. 2 112
LAN or WAN ? 11 95
Delphi Seattle StructureView color 1 14
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

860 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