CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Guest

    about PropertySheet DDX

    PropertySheet do DDX automatically when pages changed or OK clicked,
    but I need know which page is selected just before I click OK and
    only this page's data are needed, how can I ?


  2. #2
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: about PropertySheet DDX

    How about CPropertySheet::GetActivePage()?

    Rail

    ------------
    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    http://home.earthlink.net/~railro/
    [email protected]

  3. #3
    Join Date
    Aug 1999
    Location
    Toronto, ON
    Posts
    80

    Could be more detailed?

    Should I overload DDX for PropertySheet?
    I cann't find OnOK of it.


  4. #4
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: Could be more detailed?

    There is an OnOK() for each of your Property Pages -- so if you add a handler for the OnOK() in each page, then you won't have to worry about finding out which page is the active page with GetActivePage() because that page's handler for OnOK() will be called.

    If you want to handle the OK button from your CPropertySheet derived class, then add a command handler for OnCommand()

    BOOL CMySheet::OnCommand(WPARAM wParam, LPARAM lParam)
    {
    if (wParam == IDOK)
    OnSheetOK();

    return CPropertySheet::OnCommand(wParam, lParam);
    }

    and create a member function which you call when the OK button is pressed:

    void CMySheet::OnSheetOK(void)
    {
    int iIndex;

    iIndex = GetPageIndex(GetActivePage()); // Gets the index of the current page
    // Page 0 is the first page

    // Do something
    }


    Rail

    ------------
    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    http://home.earthlink.net/~railro/
    [email protected]

  5. #5
    Join Date
    Aug 1999
    Location
    Toronto, ON
    Posts
    80

    Thx, but

    It seems PropertySheet atomatically call all OnOK of the pages have been switched, since page0 is the default page, it's OnOK is always called.


  6. #6
    Join Date
    Aug 1999
    Location
    Denmark
    Posts
    36

    Re: Thx, but

    Your last post is a little unclear but:
    If you want to skip the default implementation of the "OK"-button just override OnCommand and handle it yourself as explained by Jon and return TRUE, like:


    BOOL CMyPropSheet::OnCommand(WPARAM wParam, LPARAM lParam)
    {
    switch(wParam)
    {
    case IDOK:
    //Handle OK here
    return TRUE; //skip default implementation

    default:
    break;
    };

    return CPropertySheet::OnCommand(wParam, lParam);
    }




    Hope this isn't competely off-topic!
    Good luck!



  7. #7
    Join Date
    Aug 1999
    Location
    Denmark
    Posts
    36

    Re: Thx, but

    I made a grave mistake. Disregard that last post



  8. #8
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: Thx, but

    Could you give me your objective, so I could try and get a feel for what you're ultimately trying to achieve.

    In the example that I posted - if the second page is Active when the user presses the IDOK button, then the value for iIndex is 1.

    Thanks.

    Rail

    ------------
    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    http://home.earthlink.net/~railro/
    [email protected]

  9. #9
    Join Date
    Aug 1999
    Location
    Toronto, ON
    Posts
    80

    My Objective

    to make a property sheet, each tab has its own function, like this:
    when select first page and click OK, the program draw a box use the data in the first page;
    when slect the second page and click OK, it draw a sphere use the data in the second page, etc.
    I think it's easy, but always confused.

    Thanks,




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