Chapter 16: Text-Based Controls Visual C++ and MFC Fundamentals
// TODO: Add your specialized code here
// A pointer to button we will need
CButton *btnApply;
// We will need to location and dimensions of the Apply button
CRect RectAppl;
// 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);
// Convert the location and dimensions to screen coordinates
ScreenToClient(&RectApply);
CButton *Whatever = new CButton;
Whatever->Create("&Whatever", WS_CHILD | WS_VISIBLE,
CRect(6, RectApply.top, 85,
RectApply.top+RectApply.Height()),
this, 0x188);
return bResult;
}
Another issue you would deal with is each of the messages sent by your dynamic button.
As seen on the above picture, manipulating one button has no influence on the other(s).
For example, if you destroy the Cancel button, the OK button does not move to the right.
You would have to reposition any button as you judge it necessary.
We have already mentioned that, by standard and by design, the Apply button is disabled
when the property sheet comes up. It is supposed to become enabled once the user gets
any control “dirty”, that is, once a control, any control, is not the same as it was when the
dialog box came up, the Apply button becomes available. To enable this control