如何从属性表中删除确定,取消和应用按钮

How to remove ok,cancel and apply button from property sheets

本文关键字:取消 应用 按钮 从属性 删除      更新时间:2023-10-16

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

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

提前谢谢。

使用 PSH_NOAPPLYNOW 隐藏属性表中的应用按钮

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

隐藏确定和取消按钮可以在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;
}

在属性表中:

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 )
}