OWLNext 7.0
Borland's Object Windows Library for the modern age
|
Static controls are usually unchanging units of text or simple graphics.
The user does not interact with static controls, although your application can change the static control's text.
See EXAMPLES\OWL\OWLAPI\STATIC for an example showing static controls.
Because the user never interacts directly with a static control, the application does not receive control-notification messages from static controls. Therefore, you can construct most static controls with -1 as the control ID. However, if you want to use TWindow::SendDlgItemMessage() to manipulate the static control, you need a unique ID.
One of TStatic's constructors is declared as follows:
It takes the seven parameters commonly found in this form of a control object constructor (a parent window, a resource ID, the control's x, y, h, and w dimensions, and an optional module pointer), and two parameters specific to static controls: the text string the static control displays and its maximum length (including the terminating NULL). A typical call to construct a static control looks like this:
If you want to be able to change the static control's text, you need to assign the control object to a data member in the parent window object so you can call the static control object's member function. If the static control's text does not need to change, you do not need a data member.
TStatic gets the default control styles (WS_CHILD, WS_VISIBLE, WS_GROUP, and WS_TABSTOP), adds SS_LEFT (to left-align the text), and removes the WS_TABSTOP style (to prevent the user from selecting the control using Tab). To change the style, modify Attr.Style in the static control object's constructor. For example, the following code centers the control's text:
To indicate a mnemonic for a nearby control, you can underline one or more characters in the static control's text string. To do this, insert an ampersand (&) in the string immediately preceding the character you want underlined.
For example, to underline the T in Text, use &Text. If you want to use an ampersand character in the string, use the static style SS_NOPREFIX.