0

So I tried using this code and it's not working:

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

Thanks in advance.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
Rani
  • 21
  • 1
  • 2
    What errors are you getting? Please be specific with what you are asking. – sparkitny Jan 02 '18 at 07:56
  • 2
    Not really related to your problem, but you have an incorrect argument for `ShowWindow()`. It should be `SW_HIDE` instead of `FALSE`. You are just lucky that both `FALSE` and `SW_HIDE` evaluate to `0`. – zett42 Jan 02 '18 at 08:26

2 Answers2

6

Use PSH_NOAPPLYNOW to hide the apply button in PropertySheet

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

Hiding OK and Cancel button can be handled in CPropertyPage, a handle to parent window is required because the buttons are in parent window not in page window:

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

or in property sheet:

BOOL CMyPropertySheet::OnInitDialog()
{
    BOOL res = CPropertySheet::OnInitDialog();
    GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
    GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
    return res;
}
Barmak Shemirani
  • 30,904
  • 6
  • 40
  • 77
0

In your property sheet:

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 )
}
41 72 6c
  • 1,600
  • 5
  • 19
  • 30