I am probably going about this the wrong way but I have been searching the web for about 1 week off and on and I can't think for the life of me how to solve this.
Problem:
I have an 'Options' PropertyPage which allows a user to change optional values. These values are stored in a [bold]struct[/bold] and are used on the other two PropertyPages. What I want to do is have a central accessable struct that I can reference from the three CPropetyPage's. Now I have tried putting this in the CMainApp .cpp and .h, and in the PropertySheet but I may have made a mistake in the code.
Request:
Can you please give me guidance on the best way to have a variable that can be referenced and changed by multple CPropertyPages?
Code:
Code:
Main.h
typedef struct t_Information {
int serialNumberUndertest;
int testCycles;
int successCycles;
} Information;
class CMainApp : public CWinApp
{
public:
CMainApp ();
Information testInfo;
};
extern CMainApp theApp;
Main.cpp
Code:
CMainApp ::CMainApp ()
{
}
BOOL CMainApp ::InitInstance()
{
AfxEnableControlContainer();
CTopSheet TopSheet(_T("Test Center"));
CMainDlg MainSheet;
COptionDlg OptionSheet;
CPollDlg PollSheet;
TopSheet.AddPage(&MainSheet);
TopSheet.AddPage(&PollSheet);
TopSheet.AddPage(&OptionSheet);
m_pMainWnd = &TopSheet;
INT_PTR nResponse = TopSheet.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
return FALSE;
}
MainDlg.cpp
Code:
CMainDlg::CMainDlg(CWnd* pParent /*=NULL*/)
: CPropertyPage(CMainDlg::IDD)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
pThisOptions = &myApp.testingInformation.currentOptions;
pThisData = &myApp.testingInformation;
NfcDrv_Import(&myApp.vpNfc);
return;
}
MainDlg.h
Code:
class CMainDlg : public CPropertyPage
{
public:
ModuleInformation* pThisData;
}
TopSheet.h
Code:
class CTopSheet : public CPropertySheet
{
protected:
ModuleInformation* pThisData;
}
TopSheet.cpp
Code:
CTopSheet ::CTopSheet ()
{
pThisData = &testingInformation;
}
COptionDlg.h
Code:
class COptionDlg: public CPropertyPage
{
public:
ModuleInformation* pThisData;
}
COptionDlg.cpp
Code:
COptionDlg::COptionDlg() : CPropertyPage(COptionDlg::IDD)
{
pThisOptions = &myApp.testingInformation.currentOptions;
}