Chapter 16: Text-Based Controls Visual C++ and MFC Fundamentals
BOOL CGeomeSheet::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();// TODO: Add your specialized code here
// A pointer to each button we will need
CButton *btnOK, *btnCancel, *btnApply, *btnHelp;
// We will need to location and dimensions of Apply and Help
CRect RectApply, RectHelp;// Get handles to the OK and Cancel buttons
btnOK = reinterpret_cast<CButton *>(GetDlgItem(IDOK));
btnCancel = reinterpret_cast<CButton *>(GetDlgItem(IDCANCEL));// Get a handle to the Apply button
btnApply = reinterpret_cast<CButton *>(GetDlgItem(ID_APPLY_NOW));
// Get the location and the dimensions of the Apply button
btnApply->GetWindowRect(&RectApply);// Get a handle to the Help button
btnHelp = reinterpret_cast<CButton *>(GetDlgItem(IDHELP));
// Get the location and the dimensions of the Help button
btnHelp->GetWindowRect(&RectHelp);// Dismiss the Apply and the Help buttons
btnApply->DestroyWindow();
btnHelp->DestroyWindow();// Convert the location and dimensions to screen coordinates
ScreenToClient(&RectApply);
ScreenToClient(&RectHelp);// Put the OK button where the Apply button was
btnOK->SetWindowPos(NULL, RectApply.left, RectApply.top, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
// Put the Cancel button where the Help button was
btnCancel->SetWindowPos(NULL, RectHelp.left, RectHelp.top, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);return bResult;
}- Test the application