这就是我最终解决此问题的方式。我现在从以下位置调用此代码CMFCPropertySheet::OnInitDialog()
:
void CVisitsRotaPropertySheet::SetupButtons()
{
CRect rctOK, rctCancel;
CString strButtonText;
// Get the position if the IDOK button
GetDlgItem(IDOK)->GetWindowRect(rctOK);
ScreenToClient(rctOK);
// Get the position of the IDCANCEL button
GetDlgItem(IDCANCEL)->GetWindowRect(rctCancel);
ScreenToClient(rctCancel);
// Hide the IDCANCEL button
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
// Move the IDOK button to be in the same place as the IDCANCEL button
GetDlgItem(IDOK)->MoveWindow(rctCancel);
// Create the PREVIEW button in the original location of the IDOK button
ENSURE(strButtonText.LoadString(IDS_STR_PREVIEW));
m_btnPreview.Create(strButtonText,
BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, rctOK, this, IDC_BUTTON_PREVIEW);
m_btnPreview.SetFont(GetFont());
}
上面的代码根据我的需要调整按钮。然后,在我的CMFCPropertyPage::OnInitDialog()
处理程序中,我调用CancelToClose()
.
结果:
