Chapter 12: Dialog-Based Windows Visual C++ and MFC Fundamentals
CString StrClsName = AfxRegisterWndClass(
CS_VREDRAW | CS_HREDRAW,
LoadCursor(NULL, IDC_CROSS),
(HBRUSH)GetStockObject(BLACK_BRUSH),
LoadIcon(NULL, IDI_WARNING));
First->Create(StrClsName, NULL, WS_CHILD, );
}
void CSecondDlg::OnSecondControl()
{
// TODO: Add your control notification handler code here
CWnd *Second = new CWnd;
Second->Create(NULL, NULL, WS_CHILD, );
}
void CSecondDlg::OnThirdControl()
{
// TODO: Add your control notification handler code here
CWnd *Memo = new CWnd;
Memo->Create("EDIT", "Voice Recorder", WS_CHILD, );
}
void CSecondDlg::OnFourthControl()
{
// TODO: Add your control notification handler code here
CStatic *Label = new CStatic;
Label->Create("United Nations", WS_CHILD, );
}
The WS_CHILD style is defined in the Win32 library as:
#define WS_CHILD 0x40000000L
11.4.2..Visibility................................................................................................
If you want to display a control to the user when the parent window comes up, at design
time, set the Visible property to True. If you are programmatically creating the control,
add the WS_VISIBLE style. Here is an example:
void CSecondDlg::OnSecondControl()
{
// TODO: Add your control notification handler code here
CWnd *Second = new CWnd;
Second->Create(NULL, NULL, WS_CHILD | WS_VISIBLE, );
}
The visibility style is defined as:
#define WS_VISIBLE 0x10000000L
The child style combined with the visibility style produces: