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 ?
Printable View
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 ?
How about CPropertySheet::GetActivePage()?
Rail
------------
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro/
[email protected]
Should I overload DDX for PropertySheet?
I cann't find OnOK of it.
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]
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.
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!
I made a grave mistake. Disregard that last post :(
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]
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,