0

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

oPropSheet.AddPage(&oPropSettingCriteria);
oPropSheet.AddPage(&oPropAdvancedSetting);

if(oPropSheet.DoModal() == IDOK)
{
}
...

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

I tried using
oPropSheet.GetDlgItem(IDOK)->EnableWindow(FALSE);
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..
shizu..

4
Contributors
8
Replies
10
Views
7 Years
Discussion Span
Last Post by shizu
0

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..
shizu..

0

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
    GetDlgItem(IDCANCEL)->ShowWindow(FALSE);

    // Disable the OK button
    GetDlgItem(IDOK)->EnableWindow(FALSE);

    return bResult;
}
0

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..
shizu

0

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.

0

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..

Thanks..

0

... 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))
    {
        pParent->GetDlgItem(IDCANCEL)->ShowWindow(FALSE);
        pParent->GetDlgItem(IDOK)->EnableWindow(FALSE);
    }

    return bResult;
}
0

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..
shizu..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.