|Simple Animated Bit- and SpeedButtons
How do I create buttons with animated bitmaps?
One thing that's not well-known (or maybe more accurately, not too obvious) is that the glyphs used for bit buttons are actually multi-framed bitmaps arranged horizontally from left to right. The rule is that you can have up to four frames in the bitmap, with each frame representing a particular button state. What you normally see is the first frame of the bitmap displayed on the button; this glyph represents the "up" state of the button. The other frames represent other states. Here's their layout:
____ ____ ____ ____ | || || || | | 1 || 2 || 3 || 4 | |____||____||____||____|
Figure 1 - The arrangement of a multi-framed bitmap
Table 1 describes what each bitmap frame represents:
Table 1 - Description of multi-image bitmap frames and when they're used
So what's the point to all this? Armed with the information I just provided, you can create simple, two-frame animations that will show a different picture based upon the up or down state of a button. Here's sample:
The bitmap above shows a bitmap that I use for a product that I created that runs on a CD. Frame one (the leftmost bitmap) is displayed with the button is in its up position. Frame two displayes when the button is disabled, and frame three displays when the button is pressed. Notice in frame three how the logo and CD have "moved" down and to the right, and the shadow disappears. The net effect achieved here is that the logo appears to move down as the button is pressed.
So how do you construct the bitmaps? I've found that the image editor works just great. Just create a new bitmap by selecting File|New|Bitmap from the main menu. When the image properties dialog box appears on the screen, set the dimensions like so:
Then all you have to do is use your imagination to create your bitmaps. Have fun!
Copyright © 1997 Brendan V. Delumpa All Rights Reserved
|Copyright © The Delphi Corner 2001 All Rights Reserved