Buttons Sample
This sample is located in \Samples\afc11\Buttons.
Description
Using the Sample
Key Project Files
Technologies Demonstrated
Description
This sample shows how to use AFC graphics and effects classes to create various types of button controls. The sample displays a panel that contains the following elements:
- The Button Types control provides radio buttons and check boxes for selecting different button types.
- The Button Status control displays status information on the selected buttons.
- The Button Test Area displays the results of selecting different button types. This area contains a sample button plus a graphic of the Earth in space that shows the button's behavior when pressed.
The UIPushButton option is checked by default, and a large button is displayed with an FxTexture background and a left-centered label (UIItem). As you press the button, the small globe turns on a background, using an FxTexture to indicate that an action Event has occurred.
Using the Sample
To use the sample
You can manipulate the panel's buttons by performing the following actions:
- Clear the RAISED option to give the button a flat look. If you pass the mouse over the button or if the button receives focus, it pops up and becomes three-dimensional. This indicates that focus has been received and the button can be clicked.
- Clear the THICK option to replace the default two-pixel border with a single-pixel border.
- Clear and select the TOGGLE option to change the style of the button, enabling both the checked and unchecked states. If the TOGGLE option is checked, the button stays pressed when clicked until it is clicked again. If TOGGLE is unchecked, the button returns to its original state after being clicked.
- Select UICheckButton to display a custom button. You can turn the custom look off and return to the standard Microsoft® Win32® check button by clearing the Custom check box. As the custom button in the test area is clicked, the globe turns to indicate an action Event has occurred, and the button cycles through its three separate TRITOGGLE states: unchecked, checked, and indeterminate. Clearing the TRITOGGLE option limits the button to checked and unchecked states.
- Select the UIRadioButton option to display a default custom button; clearing Custom returns you to the standard Win32 radio button. When a custom button is not selected, the Disabled option is available, allowing the radio button to be shaded and disabled.
- Select UIRepeatButton to display a large button with a left-centered Press Me label. Holding the button down generates repeated action Events, which keeps the globe turning smoothly. If the Disabled option is selected, the button is shaded and disabled.
- If you use the mouse to hover over a UIRepeatButton or UIPushButton in the Button Test Area, ToolTips appear.
Key Project Files
SDKCtrlPnl.java
This class extends com.ms.ui.UIPanel and implements a container for multiple components. Its methods create and initialize buttons and status information, control the button display, and generate associated events.
SDKConsts.java
This interface defines an array of graphics and holds the constants for button states and events.
SDKCallbacks.java
This interface is an event listener used to set button states.
Technologies Demonstrated
AFC
- This sample shows how to use AFC graphics and effects classes to create various types of button controls.
© 1999 Microsoft Corporation. All rights reserved. Terms of use.