0

这听起来像是一个愚蠢的问题。我知道CMFCPropertyPage有一个CancelToClose方法,但我找不到工作表对象的类似方法。

我基本上希望“取消”按钮始终为“关闭”,并希望在工作表对象中执行此操作。

CancelToClose是通过调用每个页面来做到这一点的唯一方法吗?

我读了这篇文章,现在意识到这不是我想要的。

这就是我想要在我的工作表上的内容:

  1. 自定义预览按钮。
  2. 关闭按钮。

预览按钮将位于关闭按钮的左侧。我找到了有关添加自定义按钮的教程。

对于关闭按钮,我不知道该怎么做。

更新

所以,目前我有:

床单

所以它有自定义按钮(现有隐藏IDOK按钮所在的位置)。它有IDCANCEL按钮。但我希望按钮为“关闭”。

我知道我可以使用SetWindowText,但我正在考虑本地化,所以我想知道最好的方法是什么。

4

1 回答 1

0

这就是我最终解决此问题的方式。我现在从以下位置调用此代码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().

结果:

使用自定义按钮

于 2018-11-10T17:52:05.023 回答