Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Toolkit User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

4.5 Button Class Hierarchy

The button class hierarchy is as follows:

Figure 13: Objective Toolkit Button Class Hierarchy

4.5.1 SECOwnerDrawButton

The SECOwnerDrawButton class is an abstract base class that simplifies creating an owner-draw button. To create an owner-draw button, provide a method to draw the face of the button and a focus rectangle on the face of the button. You do not need to consider the state of the button (up, down, disabled, etc.) or draw the borders around the edge of the button.

4.5.2 Using SECOwnerDrawButton

You can attach objects instantiated from SECOwnerDrawButton-derived classes to dialog resources, or you can create them dynamically.

4.5.2.1 To attach an SECOwnerDrawButton to a button resource in a dialog

  1. Create a derived class from SECOwnerDrawButton. You must provide an implementation for the pure virtual methods DrawFocus() and DrawSpecific().

  2. Create a button resource in the resource editor. The button resource must have the BS_OWNERDRAW style in its Properties dialog.

  3. Instantiate an object from the SECOwnerDrawButton-derived class in your dialog. This object must be in scope when the dialog appears.

  4. Attach the SECOwnerDrawButton-derived class to the dialog resource using the AttachButton() method.

4.5.2.2 To create SECOwnerDrawButtons without using a button dialog resource

  1. Create a class derived from SECOwnerDrawButton. You must provide an implementation for the pure virtual methods DrawFocus() and DrawSpecific().

  2. Create a unique control ID for the button. In Visual Studio, you can create a control ID in the Resource Includes dialog.

  3. Instantiate an object of the SECOwnerDrawButton-derived class for each button you want to create.

  4. Create the button using your SECOwnerDrawButton-derived by calling the Create() method.

4.5.3 Customizing SECOwnerDrawButton

The SECOwnerDrawButton class has overridable methods that allow you to customize the drawing of the button. Note that the DrawFocus() and DrawSpecific() are pure virtual methods that must be implemented before any derived class can be instantiated.

4.5.3.1 To extend the SECOwnerDrawButton class

4.5.4 SECBitmapButton

The SECBitmapButton class encapsulates the behavior of a bitmap button, displaying a bitmap and an optional text caption on the face of the button.

4.5.5 Using SECBitmapButton

You can attach objects instantiated from the SECBitmapButton to dialog resources or create them dynamically.

4.5.5.1 To attach an SECBitmap Button to a dialog resource

  1. Create a button resource in the resource editor. The button resource must have the BS_OWNERDRAW style set in its Properties dialog.

  2. Instantiate an SECBitmapButton object in your dialog class. This object must be in scope when the dialog is displayed.

  3. Attach the SECBitmapButton class to the dialog resource using the AttachButton() method.

4.5.5.2 To create SECBitmapButtons without using a button dialog resource

  1. Create a unique control ID for each button you want. In Visual Studio, you can create a control ID with the Resource Includes dialog in Visual Studio.

  2. For each button you want to create, instantiate an SECBitmapButton object.

  3. Create the button by calling the Create() method.

4.5.6 SECBitmapButton alignment

The placement of the bitmap and a caption (if present) is specified during initialization of the SECBitmapButton using either the AttachButton() or Create() method. There are five alignment modes for the placement of the bitmap and the placement of the caption.

Table 4: Alignment Mode Flags

Alignment mode flag Alignment of bitmap and caption
SECBitmapButton::Al_Left Bitmap on left, caption on right
SECBitmapButton::Al_Right Bitmap on right, caption on left
SECBitmapButton::Al_Top Bitmap on top, caption underneath
SECBitmapButton::Al_Bottom Bitmap underneath, caption on top
SECBitmapButton::Al_Center Bitmap in center of button, no caption.

4.5.7 SECMenuButton

The SECMenuButton class provides a simple button that displays a pop-up menu when you click it. The application can display this pop-up menu either to the right or below the button.

4.5.8 Using SECMenuButton

You can attach objects instantiated from the SECMenuButton class to dialog resources or create them dynamically.

4.5.8.1 To attach an SECMenuButton to a dialog resource

  1. Create a button resource in the resource editor. The button resource must have the BS_OWNERDRAW style set in the button resource Properties.

  2. Instantiate an SECMenuButton object in your dialog class. This object must be in scope when the dialog is displayed.

  3. Attach the SECMenuButton class to the dialog resource using the AttachButton() method. Specify a menu handle and the placement of the menu through parameters, or call the SetMenu() and SetDirection() methods for altering the menu and its placement dynamically.

4.5.8.2 To create SECMenuButtons without using a button dialog resource

  1. Create an unique control ID for each button you want. In Visual Studio, you can create a control ID in the Resource Includes dialog.

  2. For each button you want to create, instantiate an SECMenuButton object.

  3. Create the button by calling the Create() method. Specify a menu handle and the placement of the menu through parameters, or call the SetMenu() and SetDirection() methods for altering the menu and its placement dynamically.

4.5.9 SECMenuButton Menu Placement

You can specify the placement of the menu with respect to the button using direction flags, which are parameters to the AttachButton(), Create(), or SetDirection() methods. These flags are as follows.

Table 5: Direction Flags

Direction flag Placement of menu
SECMenuButton::DT_Down Menu drops down from the button
SECMenuButton::DT_Right Menu appears to the right of the button

4.5.10 SECWellButton

The SECWellButton class includes a Color Selection button. The face of the button displays the currently selected color. When the user clicks the button, a color palette (or color well) appears below the button. The user can select a color by clicking it.

The SECWellButton class sends a CWN_COLOR_CHANGE message to its parent window when you select a new color.

If you are using AttachButton(), ensure that the original BS_OWNERDRAW button style is defined.

4.5.11 Using SECWellButton

You can attach objects instantiated from the SECWellButton class to dialog resources, or create them dynamically.

4.5.11.1 To attach an SECWellButton to a dialog resource

  1. Create a button resource in the resource editor. The button resource must have the BS_OWNERDRAW style set in the button resource Properties.

  2. Instantiate an SECWellButton object in your dialog class. This object must be in scope when the dialog is displayed.

  3. Attach the SECWellButton class to the button resource using the AttachButton() method.

  4. Use the SetColor() and GetColor() methods to set and obtain the currently selected color in the control. You can also use the DDX_Color() function as part of a DoDataExchange() method.

4.5.11.2 To create SECWellButtons without using a button dialog resource

  1. Create a unique control ID for each button you need. In Visual Studio, you can create a control ID in the Resource Includes dialog.

  2. For each button you want to create, instantiate an SECWellButton object.

  3. Create the button by calling the Create() method.

  4. Use the SetColor() and GetColor() methods to set and obtain the currently selected color in the control. You can also use the DDX_Color() function as part of a DoDataExchange() method.

4.5.12 Customizing SECWellButton

The SECWellButton provides the following virtual methods so you can customize its behavior:



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.