-1

所以我尝试使用这段代码,但它不起作用:

CButton *btnApply;
btnApply = reinterpret_cast<CButton *>(GetDlgItem(IDOK));
btnApply->ShowWindow(FALSE);

提前致谢。

4

2 回答 2

5

用于PSH_NOAPPLYNOW隐藏 PropertySheet 中的应用按钮

CMyPropertySheet psheet;
psheet.m_psh.dwFlags |= PSH_NOAPPLYNOW;
psheet.DoModal();

隐藏 OK 和 Cancel 按钮可以在 中处理CPropertyPage,需要父窗口的句柄,因为按钮在父窗口中而不是在页面窗口中:

BOOL CMyPropertyPage::OnSetActive()
{
    BOOL res = CPropertyPage::OnSetActive();
    CPropertySheet* psheet = (CPropertySheet*)GetParent();
    psheet->GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
    psheet->GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
    return res;
}

或在属性表中:

BOOL CMyPropertySheet::OnInitDialog()
{
    BOOL res = CPropertySheet::OnInitDialog();
    GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
    GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
    return res;
}
于 2018-01-02T08:07:17.580 回答
0

在您的属性表中:

BOOL CMyPropertySheet::OnInitDialog()
{
    CWnd *pWnd = GetParent()->GetDlgItem(IDHELP);
        pWnd->ShowWindow( FALSE );

        CWnd *pWnd1 = GetParent()->GetDlgItem(IDCANCEL);
        pWnd1->ShowWindow( FALSE );

        CWnd *pWnd2 = GetParent()->GetDlgItem(IDOK);
        pWnd2->ShowWindow( FALSE );

        CWnd *pWnd3 = GetParent()->GetDlgItem(0x3021);// 0x3021 == IDAPPLY
        pWnd3->ShowWindow( FALSE )
}
于 2019-09-12T07:32:55.110 回答