CStatic::Create

Syntax

BOOL Create( const char FAR* lpText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff );

Parameters

lpText

Specifies the text to place in the control. If NULL, no text will be visible.

dwStyle

Specifies the static control's window style.

rect

Specifies the position and size of the static control. It can be either a RECT structure or a CRect object.

pParentWnd

Specifies the CStatic parent window, usually a CDialog or CModalDialog object. It must not be NULL.

nID

Specifies the static control's resource ID.

Remarks

You construct a CStatic object in two steps. First call the constructor CStatic, then call Create, which creates the Windows static control and attaches it to the CStatic object.

Apply the following window styles to a static control:

Style Application

WS_CHILD Always.
WS_VISIBLE Usually.
WS_DIABLED Rarely.

See CreateEx in the CWnd base class for a full description of these window styles.

Use any combination of the following static control styles for dwStyle:

Style Meaning

SS_BLACKFRAME Specifies a box with a frame drawn with the same color as window frames. The default is black.
SS_BLACKRECT Specifies a rectangle filled with the color used to draw window frames. The default is black.
SS_CENTER Designates a simple rectangle and displays the given text centered in the rectangle. The text is formatted before it is displayed. Words that would extend past the end of a line are automatically wrapped to the beginning of the next centered line.
SS_GRAYFRAME Specifies a box with a frame drawn with the same color as the screen background (desktop). The default is gray.
SS_GRAYRECT Specifies a rectangle filled with the color used to fill the screen background. The default is gray.
SS_ICON Designates an icon displayed in the dialog box. The given text is the name of an icon (not a filename) defined elsewhere in the resource file. The nWidth and nHeight parameters are ignored; the icon automatically sizes itself.
SS_LEFT Designates a simple rectangle and displays the given text flush-left in the rectangle. The text is formatted before it is displayed. Words that would extend past the end of a line are automatically wrapped to the beginning of the next flush-left line.
SS_LEFTNOWORDWRAP Designates a simple rectangle and displays the given text flush-left in the rectangle. Tabs are expanded, but words are not wrapped. Text that extends past the end of a line is clipped.
SS_NOPREFIX Unless this style is specified, Windows will interpret any ampersand (&) characters in the control's text to be accelerator prefix characters. In this case, the ampersand (&) is removed and the next character in the string is underlined. If a static control is to contain text where this feature is not wanted, SS_NOPREFIX may be added. This static-control style may be included with any of the defined static controls.
  You can combine SS_NOPREFIX with other styles by using the bitwise-OR operator. This is most often used when filenames or other strings that may contain an ampersand (&) need to be displayed in a static control in a dialog box.
SS_RIGHT Designates a simple rectangle and displays the given text flush-right in the rectangle. The text is formatted before it is displayed. Words that would extend past the end of a line are automatically wrapped to the beginning of the next flush-right line.
SS_SIMPLE Designates a simple rectangle and displays a single line of text flush-left in the rectangle. The line of text cannot be shortened or altered in any way. (The control's parent window or dialog box must not process the WM_CTLCOLOR message.)
SS_USERITEM Specifies a user-defined item.
SS_WHITEFRAME Specifies a box with a frame drawn with the same color as window backgrounds. The default is white.
SS_WHITERECT Specifies a rectangle filled with the color used to fill window backgrounds. The default is white.

Return Value

TRUE if successful; otherwise FALSE.

See Also

CStatic::CStatic