CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Location
    Romania
    Posts
    70

    propertysheet - how to enable/disable buttons ?

    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 .



  2. #2
    Join Date
    Oct 1999
    Location
    Tokyo.JP
    Posts
    7

    Re: propertysheet - how to enable/disable buttons ?

    Do the same thing in this way seems OK:

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



  3. #3
    Join Date
    May 1999
    Location
    Romania
    Posts
    70

    Re: propertysheet - how to enable/disable buttons ?

    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.


  4. #4
    Join Date
    Oct 1999
    Location
    Tokyo.JP
    Posts
    7

    Re: propertysheet - how to enable/disable buttons ?

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured