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

4.9 Currency Edit Control

The Objective Toolkit currency edit control classes provide a specialized edit control for the display and entry of currency data. The control includes a bitmap button for dropping down a calculator.

Figure 23: Objective Toolkit's Currency Edit Class Hierarchy

4.9.1 SECDropEdit

The SECDropEdit class adds a combo-like drop-down button to an edit control.

SECCurrencyEdit uses the special SECDropEdit capabilities to display a bitmap button that activates a calculator to help in the data entry.

4.9.2 SECCurrencyEdit

SECCurrencyEdit provides an extensible class for entering and displaying custom-formatted currency data. In addition, it includes a context menu and an optional bitmap button.

The methods of the Format class, a helper class, provide a comprehensive set of custom formatting options. If you need implement behavior that is not addressed by Format's methods, you can customize the input data parsing and output display formatting by descending new classes from SECCurrencyEdit::Format and SECCurrencyEdit.

4.9.3 Using SECCurrencyEdit

To attach an SECBitmap Button to a dialog resource:

  1. Add an edit control to your dialog using the resource editor.

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

  3. In OnInitDialog(), replace the edit control with your SECCurrencyEdit object by calling the Initialize() method.

  4. Create and configure an SECCurrencyEdit::Format object to specify formatting options. Call SetFormat() to start using the new formatting information.

Use GetValue() and SetValue() to obtain and recover the current value in the control. You can also use the DDX_Currency() method in your DoDataExchange() function.

Call SetBitmap(IDB_CALC) to display the calculator drop-down button.

4.9.4 SECCurrencyEdit::Format

Format is a nested helper class that provides the core currency formatting and parsing methods used by an SECCurrencyEdit control. As the following list of methods suggests, the Format class provides extensive control over the appearance of the currency data.

Consider the following facts before you use the currency display options:

Negative Format Positive Format
0 ($1) 0 $1
1 -$1 1 1$
2 $-1 2 $ 1
3 $1- 3 1 $
4 (1$)    
5 -1$    
6 1-$    
7 1$-    
8 -1 $    
9 -$ 1    
10 $ 1-    

The ParseValue() and FormatValue() methods convert between a numeric and a string representation. If you need to use a format that is not supported by the basic Format class, derive your own Format class and override those methods. Then, derive your own version of SECCurrencyEdit and override its CreateFormatObject() method to provide an object of your descendant class.

For example, the following code:

will present "5555555" as "$ , 5,555,555.00" in blue color; and "-5555555" as "($ , 5,555,555.00)" in red color.

4.9.5 SECCurrencyEdit Messages

The SECCurrencyEdit class supports some of the WM_* windows messages and EM_* edit control messages.

The supported messages are as follows:

Table 9: Windows Messages Supported by SECCurrencyEdit

Windows Message Description
WM_COPY Copies the current selection to the clipboard.
WM_CUT Deletes or cuts the current selection, if any, in the control and then copies the deleted text to the clipboard.
WM_GETFONT Retrieves the font with which the control is currently drawing its text.
WM_PASTE Copies the current content on the clipboard to the control.
WM_SETFONT Specifies the font that the control uses when drawing text.
WM_SETREDRAW Allows changes in the control to be redrawn or prevents changes in the control from being redrawn.
WM_SETTEXT Sets the text of the control.
WM_UNDO Undoes the last operation.

Table 10: Edit Control Messages Supported by SECCurrencyEdit

Edit Control Message Description
EM_CANUNDO Determines whether the user can undo an operation.
EM_EMPTYUNDOBUFFER Resets the undo flag of the control.
EM_GETSEL Gets the starting and ending character positions of the current selection in the control.
EM_SETREADONLY Sets or removes the read-only style (ES_READONLY) of the control.
EM_SETSEL Selects a range of characters in the control.
EM_UNDO Undoes the last edit control operation.

4.9.6 SECCurrencyEdit Sample

The use of SECCurrencyEdit and its supporting classes is demonstrated in the Objective Toolkitcurrency sample in the Samples\Toolkit\MFC\Controls\currency directory. This sample is not shipped with the product. For information on how to obtain this sample, see Section 3.6.1, "Location of Sample Code," in the Stingray Studio Getting Started Guide.



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.