The Speed Button Component

The SpeedButton component was designed to be used on speedbars. It is different from the Button and BitBtn components in that it is not a windowed component. This means that a speed button cannot receive input focus and cannot be tabbed to. On the other hand, the SpeedButton component has several things in common with the BitBtn component. The way in which the Glyph property is handled by the SpeedButton component is exactly the same as with the BitBtn component, so I'm not going to go over that ground again. There are a couple major differences, though, so let's go over those.

By default, speed buttons are square and are 25x25 pixels. Your speed buttons may be any size you like and can contain text, although typically speed buttons do not contain text. There are some properties specific to speed buttons that you should be aware of, which I've broken down in the following sections.

The GroupIndex Property

Speed buttons can be grouped to make them behave like radio buttons (radio buttons are discussed later in the chapter in the section "Radio Buttons and Check Boxes"). When one button in the group is pressed, it stays down, and the button that was previously pressed pops up again. To group speed buttons, simply assign the same value to the GroupIndex property for all buttons in a group. (The default value of 0 indicates that the button is not part of any group.) To illustrate, do the following exercise:

  1. Create a blank form and place five speed buttons on the form. (I won't bother with adding glyphs to the buttons in this simple exercise, but you certainly may if you want.)
  2. Select all the buttons and change the value of the GroupIndex property to 1. The GroupIndex for all buttons will be changed to 1.
  3. Optional: Change the Down property of one of the buttons to true.
  4. Click the Run button to compile and run the program.

When you run the program, click on several of the buttons. You will notice that only one button can be in the down state at one time. As you can see when you assign a nonzero value to GroupIndex, the speed buttons change their behavior. A speed button with a GroupIndex of 0 pops back up when you click it, whereas a speed button that is part of a group stays down when clicked.

The AllowAllUp Property

By default, one button in the group must be down at all times. You can change that behavior by setting the AllowAllUp property to true. Doing this for one button automatically changes the AllowAllUp property for all other buttons in the group to true as well. Now you can have any one button in the group selected or no buttons at all.

Sometimes you want a speed button to act as a toggle button. A toggle button is used to turn an option on or off and is not part of a button group. To make an individual speed button a toggle button, assign a nonzero value to its GroupIndex property and set its AllowAllUp property to true. Be sure to set the GroupIndex property to a value not used by any other components on the form. When the user clicks the button, it stays down. When the button is clicked again, it pops back up.

The Down Property

The Down property, when read, returns true if the button is currently down and false if it is not. When written to, the Down property can be used to toggle a button as pressed or not pressed. Writing to the Down property has no effect unless the speed button is part of a group.

Was this article helpful?

+5 -2


  • Abelardo
    What is speed button component?
    9 years ago

Post a comment