Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows


corner of the parent window. The horizontal measurements move from the origin to the
right. The vertical measurements move from the origin to the bottom:

If you are programmatically creating the control, to set its location, if you are using the
CreateWindow(), the CreateWindowEx() functions, or the first version of the
CreateEx() method, specify the value for the distance from the left border of the body of
the parent to the left border of the control, and pass the desired value for the upper
distance from the top border of the body of the parent to the top border of the control.
Here is an example:

BOOL CBordersDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here
CWnd* Panel = new CStatic;

Panel->CreateEx(NULL, "STATIC", NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER,
32, 15, );

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Free download pdf