Property Sheet w/tabs, how to Set/GetActivePage?

In my program I have a Property sheet with multiple tabs. What should I use to 'Get' and 'Set' the Active tabs in the sheet? I tried using GetActiveIndex to find what tab I am on, but it is always 0. Since I cannot get past the 'Get' milestone, I haven't been able to try any 'Set' functions.
[337 byte] By [Ciralia] at [2007-11-19 19:41:11]
# 1 Re: Property Sheet w/tabs, how to Set/GetActivePage?
SetActivePage
GetActiveIndex

Works for me, perhaps you can post some of your code so others can help you.
ThatIowaGuy at 2007-11-10 23:43:07 >
# 2 Re: Property Sheet w/tabs, how to Set/GetActivePage?
This is how my property sheet is declared:

class CMyPropertySheet : public CPropertySheetImpl<CMyPropertySheet>

where CPropertySheetImpl is derived from CPropertySheet.

This is what I tried (this code is inside the OnOk function):

CPropertySheet *myPropertySheet;
int activeIndex = myPropertySheet->GetActiveIndex();
SetActivePage(activeIndex);

The GetActiveIndex line just returned 0, and therefore nothing happens.
Ciralia at 2007-11-10 23:44:07 >
# 3 Re: Property Sheet w/tabs, how to Set/GetActivePage?
It doesn't appear that you have added any pages to the propertysheet, have you done this?
ThatIowaGuy at 2007-11-10 23:45:11 >
# 4 Re: Property Sheet w/tabs, how to Set/GetActivePage?
Yes, sorry I didn't include that code. There are 6 pages in the property sheet, and they are all successfully created. We can just call them page alpha, beta..etc..

This is how they were created:

I have a class that links the actually page dialogs to variables such as m_alpha or m_beta.

The pages are then added like so:

AddPage(m_alpha.Create());
Ciralia at 2007-11-10 23:46:10 >
# 5 Re: Property Sheet w/tabs, how to Set/GetActivePage?
Which page is selected? If it is the first one, I think that GetActivePage will return 0 as it is the first in the index, which is zero based.

For grins try the GetPageCount to make sure that the program thinks that it has as many pages as you do.
ThatIowaGuy at 2007-11-10 23:47:09 >
# 6 Re: Property Sheet w/tabs, how to Set/GetActivePage?
This section of code returns 0 no matter where I put it, which doesn't make sense because the pages DO get created.

CMyPropertySheet *myPropertySheet;
int pageCount = myPropertySheet->GetPageCount();
CString pCount;
pCount.Format("%d", pageCount);
MessageBox(pCount, "test", MB_OK);
Ciralia at 2007-11-10 23:48:13 >
# 7 Re: Property Sheet w/tabs, how to Set/GetActivePage?
I dont know what to tell you. How do you know that the pages are getting created correctly?
ThatIowaGuy at 2007-11-10 23:49:17 >
# 8 Re: Property Sheet w/tabs, how to Set/GetActivePage?
Why are you using *myPropertySheet? Is the pointer valid? I do not see it being set to anything. What about:
int activeIndex = GetActiveIndex();

CPropertySheet *myPropertySheet;
int activeIndex = myPropertySheet->GetActiveIndex();
SBarber at 2007-11-10 23:50:17 >