Hi all..

I had a part of code like below..

CPropertySheet oPropSheet("Page", NULL, 0);

oPropSheet.m_psh.dwFlags |= PSH_NOAPPLYNOW;
oPropSheet.m_psh.dwFlags &= ~(PSH_HASHELP);


if(oPropSheet.DoModal() == IDOK)

now I would like to hide or disable OK button..just left only CANCEL button there..

I tried using
but will have application error due to oPropSheet's m_hwnd = NULL..

Anyone can tell me how to do it..??
I able to hide APPLY NOW button..but no able to hide or disable OK button.

Thank you..

Recommended Answers

All 8 Replies

Can you hide the CANCEL button? If so, process Cancel code using the OK button.

Hi WaltP..

Thanks for reply..
I cannot hide for CANCEL button also..

Any you please let me know how you hide the cancel button
if anyone of you can do so..??

Thank you..

Have you tried the following ?

// WM_INITDIALOG handler of your property sheet class
// (derived from CPropertySheet)
BOOL CMyPropertySheet::OnInitDialog() 
    BOOL bResult = CPropertySheet::OnInitDialog();

    // Hide the Cancel button

    // Disable the OK button

    return bResult;

Hi mitrmkar,

Thanks for reply..
yes, I tried that before already..but I don't have CPropertySheet's pointer inside my dialog..
It cause application error when I wrote like this.

although I am using CPropertySheet, but my dialog is CPropertyPage..
so I don't have CPropertySheet::OnInitDialog()..
I only have CPropertyPage::OnInitDialog()..

that's why my OK button have to hide before calling oPropSheet.DoModal()..

Please advise..

Thank you..

You could always enumerate all controls then get text info for your OK button caption then use SendMessage to send it WM_DISABLE, lol. I joke, that's a horrible solution.

I believe mitrmkar is implying you subclass CPropertySheet. The example he used was a subclassed constructor called "CMyPropertySheet". With a subclass you should be able to pass and manipulate whatever data you need. If the OK button is not implemented within that CPropertySheet, then really the GetDlgItem(IDOK)->EnableWindow(FALSE); call should be made in the parent (CPropertyPage?). Hope that helps.

Hi BountyX,

Thanks for reply..
I tried out the code as mitrmkar said before..
I got build no error..
during running program..
when it come to this line "getDlgItem(IDOK)->EnableWindow(FALSE);"..
a application error prompt out..
before my oPropSheet's m_hWnd = NULL..

so the solution from mitrmkar, cannot apply under my condition..

Please advise..


... so I don't have CPropertySheet::OnInitDialog()..

You could very easily arrange so that you'd have a class derived from CPropertySheet, in which case the above code snippet would do the job. I think that would be the 'most natural' way of doing what you are trying to accomplish.

I only have CPropertyPage::OnInitDialog()..

In that case you might try the following

// WM_INITDIALOG handler for your CPropSettingCriteria 
// property page class
BOOL CPropSettingCriteria::OnInitDialog() 
    BOOL bResult = CPropertyPage::OnInitDialog();

    // Try to get a pointer to the propertysheet
    CWnd * pParent = GetParent();

    if(pParent && IsWindow(pParent->m_hWnd))

    return bResult;

Hi mitrmkar,

it's work..
Thank you for save my life..

Thank you for BountyX also,
and anyone who trying solve my problem..

Thanks alot..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.