?
Solved

Showing only one image in a TSpeedButton

Posted on 2001-09-15
9
Medium Priority
?
576 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 80 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

765 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