You may:
- Add public get/set methods to the
CMyPropertySheet
(you may use a std::map
to hold {name, value}
pairs). - On creation of the pages, pass the instance of the sheet to the pages themselves. This way each page may call the get/set methods of the sheet.
For instance
#include <map>
using namespace std;
CMyPropertySheet:public CPropertySheet
{
private:
map< CString, int > m_ItemMap;
};
void CMyPropertySheet::setItem(CString key, int value)
{
m_ItemMap.insert( make_pair(key, value) );
}
bool CMyPropertySheet::getItem(CString key, int & value)
{
bool found = false;
map< CString, int >::iterator it = m_ItemMap.find( key );
if ( it != m_ItemMap.end() )
{
value = it->second;
found = true;
}
return found;
}
CMyPropertyPage1 : public CPropertyPage
{
private:
CMyPropertySheet * m_pSheet;
public:
CMyPropertyPage1(CMyPropertySheet * pSheet): m_pSheet(pSheet){}
}
and a similar modification to CMyPropertyPage2.
Now you may do:
CMyPropertySheet propSheet(L"Self Extractor") ;
CMyPropertyPage1 page1(&propSheet);
CMyPropertyPage2 page2(&propSheet);
propSheet.AddPage(&page1);
propSheet.AddPage(&page2);
And each property page may call, when needed setItem
or getItem
, for instance:
CMyPropertyPage1::OnMyBtnDown()
{
m_pSheet->setItem("FirstVar", 100);
}
:)