CStatic

Win32++

CStatic Class

Description

Applications often use static controls to label other controls or to separate a group of controls. Although static controls are child windows, they cannot be selected. Therefore, they cannot receive the keyboard focus and cannot have a keyboard interface. A static control that has the SS_NOTIFY style receives mouse input, notifying the parent window when the user clicks or double clicks the control. Static controls belong to the STATIC window class.

CStatic is the class responsible for creating a static control.

Refer to the documentation that ships with the Microsoft Windows Software Development Kit for more information on the use of static controls.

CStatic Members

Construction

CStatic
CStatic();
Constructs a CStatic

Attributes

GetBitmap
HBITMAP GetBitmap() const;
Returns the handle of the bitmap associated with the static control set by CStatic::SetBitmap.
GetCursor
HCURSOR GetCursor() const;
Returns the handle of the cursor associated with the static control set by CStatic::SetCursor.
GetEnhMetaFile
HENHMETAFILE GetEnhMetaFile() const;
Returns the handle of the enhanced metafile associated with the static control set by CStatic::SetEnhMetaFile.
GetIcon
HICON GetIcon() const;
Returns a handle to the icon associated with the static control set by CStatic::SetIcon.
SetBitmap
HBITMAP SetBitmap(HBITMAP hBitmap) const;
Associates a new bitmap with the static control. The bitmap will be drawn in the upper-left corner. The static control will be resized to the size of the bitmap. This function requires the SS_BITMAP style.
SetCursor
HCURSOR SetCursor(HCURSOR hCursor) const;
Associates a new cursor image with static control. The cursor will be drawn in the upper-left corner. The static control will be resized to the size of the cursor. This function requires the SS_ICON style.
SetEnhMetaFile
HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile) const;
Associates a new enhanced metafile image with static control. The image will be drawn in the upper-left corner. The static control will be resized to the size of the metafile image. This function requires the SS_ENHMETAFILE style.
SetIcon
HICON SetIcon(HICON hIcon) const;
Associates a new icon image with the static control. The icon will be drawn in the upper left of the static control. The static control will be resized to the size of the icon. This function requires the SS_ICON style.

Overidables

PreRegisterClass
virtual void PreRegisterClass(WNDCLASS &wc);
Set the window class parameters before the window is created.
Base class Members

For base class members, refer to the members of CWnd.

Remarks

Like all common controls, the static control requires a parent window. This parent window is often a dialog, but simple windows can also be the parent window for a static control.

Although static controls can be used in overlapped, pop-up, and child windows, they are designed for use in dialog boxes, where the system standardizes their behavior. By using static controls outside dialog boxes, a developer increases the risk that the application might behave in a nonstandard fashion. Typically, a developer either uses static controls in dialog boxes or uses the SS_OWNERDRAW style to create customized static controls.

Summary Information

Header file stdcontrols.h
Win32/64 support Yes
WinCE support Yes
Library required Comctl32.lib