I'm learning to cope with the mfc; and trying to make peace with the mostly damnable C++ language.
I have an application based on CFormView. From operator inputs thru edit controls, the View must access member functions of CDoc & CApp. My head is filled to confusion reading about scopes, statics, friends, and such. I couldn't get anything to work. I finally gave up and solved the problem.
//In CMyApp:
CMyApp* pApp; //declared at global level.
//Somewhere inside class construction:
pApp = this;
//In CFormView:
extern CMyApp* pApp;
//Any CMyApp member can be accessed now with:
pApp->MyAppMember();
This works so nicely that I'm sure I have violated some rules somewhere. How should I have done it correctly?
I have an application based on CFormView. From operator inputs thru edit controls, the View must access member functions of CDoc & CApp. My head is filled to confusion reading about scopes, statics, friends, and such. I couldn't get anything to work. I finally gave up and solved the problem.
//In CMyApp:
CMyApp* pApp; //declared at global level.
//Somewhere inside class construction:
pApp = this;
//In CFormView:
extern CMyApp* pApp;
//Any CMyApp member can be accessed now with:
pApp->MyAppMember();
This works so nicely that I'm sure I have violated some rules somewhere. How should I have done it correctly?