MFC - Static Text
A static control displays a text string, box, rectangle, icon, cursor, bitmap, or enhanced metafile. It is represented by CStatic class. It can be used to label, box, or separate other controls. A static control normally takes no input and provides no output.
Here is the list of methods in CStatic class −
Sr.No. | Name & Description |
---|---|
1 | Create Creates the Windows static control and attaches it to the CStatic object. |
2 | DrawItem Override to draw an owner-drawn static control. |
3 | GetBitmap Retrieves the handle of the bitmap previously set with SetBitmap. |
4 | GetCursor Retrieves the handle of the cursor image previously set with SetCursor. |
5 | GetEnhMetaFile Retrieves the handle of the enhanced metafile previously set with SetEnhMetaFile. |
6 | GetIcon Retrieves the handle of the icon previously set with SetIcon. |
7 | SetBitmap Specifies a bitmap to be displayed in the static control. |
8 | SetCursor Specifies a cursor image to be displayed in the static control. |
9 | SetEnhMetaFile Specifies an enhanced metafile to be displayed in the static control. |
10 | SetEnhMetaFile Specifies an icon to be displayed in the static control. |
Let us look into a simple example of Static Text.
Step 1 − Drag a Static Text control from Toolbox.
Step 2 − Change the Caption to It is Static Text Control and run your application you will see the following dialog box, which now contains the Static Text control as well.