Click to See Complete Forum and Search --> : propertysheet - how to enable/disable buttons ?


broc
October 17th, 1999, 07:33 PM
hi,
i need to disable "OK" button of a propertysheet and i don't know how to do this .
i tried something like this :

...
int CALLBACK PropSheetProc(
HWND hwndDlg, // handle to the property sheet dialog box
UINT uMsg, // message identifier
LPARAM lParam // message parameter
)
{

((CButton *)::GetDlgItem(hwndDlg,IDOK))->EnableWindow(FALSE);
return 1;
}
...
void MySettings()
{
...
m_propsheet=new CPropertySheet(_T("My propertysheet"));
m_propsheet->m_psh.dwSize=sizeof ( PROPSHEETHEADER );
m_propsheet->m_psh.dwFlags|=PSP_USECALLBACK;
m_propsheet->m_psh.pfnCallback=PropSheetProc;
m_propsheetSession->DoModal();
...
}
...



but it not work .

thanks in advance for your help .

Tiger
October 17th, 1999, 08:55 PM
Do the same thing in this way seems OK:

BOOL CMySheet::OnInitDialog()
{
BOOL fRtn = CPropertySheet::OnInitDialog();
GetDlgItem(IDOK)->EnableWindow(FALSE);
return fRtn;
}

broc
October 18th, 1999, 05:37 AM
hi .
thank you for answer but i didn't mentioned that "m_propertysheet" is a pointer member in a class and i don't want to do a "CMySheet" class just for enabling/disabling "OK" button .

...
class CMyClass
{
...
CPropertySheet *m_propsheet;
...
}
...
int CALLBACK PropSheetProc(
HWND hwndDlg, // handle to the property sheet dialog box UINT uMsg, // message identifier
LPARAM lParam // message parameter
)
{
((CButton *)::GetDlgItem(hwndDlg,IDOK))->EnableWindow(FALSE);
return 1;
}
...
void CMyClass::MySettings()
{
...
m_propsheet=new CPropertySheet(_T("My propertysheet"));
m_propsheet->m_psh.dwSize=sizeof ( PROPSHEETHEADER );
m_propsheet->m_psh.dwFlags|=PSP_USECALLBACK;m_propsheet->m_psh.pfnCallback=PropSheetProc;
m_propsheetSession->DoModal();
...
delete m_propsheet;
...
}
...




Any new suggestion ?
thanks in advance for your patience.

Tiger
October 20th, 1999, 09:39 PM
If you use CPropertySheet, the callback proc will always be AfxPropSheetCallback which setting by MFC (have a look to Mfc\Src\DlgProp.cpp please).Override the OnInitDialog() will be the most simple way to do extra initializtion.Of cause you can use the API PropertySheet() to implement your callback if you want to write many many code...
P.S. I don't think there has any trouble to do a class for a point member.