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.
# 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.
# 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?
# 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());
# 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.
# 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);
# 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?
# 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();