Access of PropertyPage members
-
Hi, I want to access member functions of my derived CPropertyPage Classes from the PropertySheet in a for loop. The problem is that I don't how to get a pointer to the correct PropertyPage Class I can do it like this
CParameterList parList; CMainPage* mainPage = GetPage(0); parList = mainPage->GetList(); DoStuff(); CDrivePage* drivePage = GetPage(1); parList = drivePage->GetList(); DoStuff(); and more
But it would make more sence if I could do it in a loopfor (int i = 0 ; i < GetPageCount(); i++) { CParameterList parList; CPropertyPage* page = GetPage(i); // Now I can only access members of the base class parList = page->GetList(); // So this would not work DoStuff(); }
van Padoea -
Hi, I want to access member functions of my derived CPropertyPage Classes from the PropertySheet in a for loop. The problem is that I don't how to get a pointer to the correct PropertyPage Class I can do it like this
CParameterList parList; CMainPage* mainPage = GetPage(0); parList = mainPage->GetList(); DoStuff(); CDrivePage* drivePage = GetPage(1); parList = drivePage->GetList(); DoStuff(); and more
But it would make more sence if I could do it in a loopfor (int i = 0 ; i < GetPageCount(); i++) { CParameterList parList; CPropertyPage* page = GetPage(i); // Now I can only access members of the base class parList = page->GetList(); // So this would not work DoStuff(); }
van Padoea- You can use IsKindOf:
CPropertyPage* page = GetPage(i); if(page.IsKindOf(RUNTIME_CLASS(CMainPage))) ((CMainPage*)page)->GetList();
2) If you have GetList() methods in all your pages, you can derive your pages from a intermediate class which defines the GetList() method as virtual:class CListPage:CPropertyPage { virtual CParameterList GetList()=0; ... } class CMainPage:CListPage { virtual CParameterList GetList(){...} ... }
Sonork 100.15206;PavelK
- You can use IsKindOf:
-
- You can use IsKindOf:
CPropertyPage* page = GetPage(i); if(page.IsKindOf(RUNTIME_CLASS(CMainPage))) ((CMainPage*)page)->GetList();
2) If you have GetList() methods in all your pages, you can derive your pages from a intermediate class which defines the GetList() method as virtual:class CListPage:CPropertyPage { virtual CParameterList GetList()=0; ... } class CMainPage:CListPage { virtual CParameterList GetList(){...} ... }
Sonork 100.15206;PavelK
Thank you, Will try option 2 first. van Padoea. If every fool wore a crown, we would all be king - Lard
- You can use IsKindOf: