Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows
- On the dialog box, click the custom control to select it
- On the Properties window, click the Class box, type Static and press Enter
- Test the application and return to MSVC
11.3.4..The Control's Window Name............................................................
The window name is a default string that displays on the control when the control comes
up. In the previous lessons, we saw that this string displays as caption on the title bar of a
window frame or a dialog box. This property is different for various controls.
To set the default text of a control, you can either do this when creating the control or
change its text at any time. Again, this can depend on the control. To set the default text
when programmatically creating the control, pass a string value as the lpszWindowName
argument of the Create() or CreateEx() method. Here is an example:
void CSecondDlg::OnThirdControl()
{
// TODO: Add your control notification handler code here
CWnd *Memo = new CWnd;
Memo->Create("EDIT", "Voice Recorder", );
}
Many (even most) controls do not use a window name. Therefore, you can pass it as
NULL.
Practical Learning: Setting a Caption
- On the dialog box, click the custom button. Then, on the Properties window, delete
the content of the Caption field. Then, in the Class field, type ListBox - Test the application and return to MSVC
11.4 Controls Styles and Common Properties.................................................
11.4.1..Childhood..............................................................................................
A style is a characteristic that defines the appearance, and can set the behavior, of a
control. The styles are varied from one control to another although they share some of the
characteristics common to most Windows controls.
All of the controls you will create need to be hosted by another control. During design,
once you position a control on a dialog box or a form, it automatically gets the status of
child. If you are programmatically creating a control, to specify that it is a child, add the
WS_CHILD to the dwStyle argument. Here are examples:
void CSecondDlg::OnFirstControl()
{
// TODO: Add your control notification handler code here
CWnd *First = new CWnd;