Click to See Complete Forum and Search --> : Global application object


Birger Thureson
March 31st, 1999, 03:21 PM
I want to retrieve my own implemented variables in the CWinApp-derived class from another class (The variables hold values from an INI-file).


How do I refer to the one and only global application object from another implemented class ( i.e CString s=theApp.myvariable )???


Please help me!

Igor Povarov
March 31st, 1999, 06:12 PM
:-)

Try to use :


extern CString s;


in other file

Ramon Saenz-Badillos
March 31st, 1999, 06:40 PM
One way is to use an extern declaration like this

class CMDIApp :public CWinApp

{//...}

extern CMDIApp theApp;

sally
March 31st, 1999, 08:02 PM
1) if you only want to read them once, the place is InitInstance

2) Create a static class, holding only static members and static functions

3) In InitInstance read from INI file and poke the values into the static class

4) Access the values from this static class whereevere you need them

5) Lycka till


Sally

Sally
March 31st, 1999, 08:02 PM
1) if you only want to read them once, the place is InitInstance

2) Create a static class, holding only static members and static functions

3) In InitInstance read from INI file and poke the values into the static class

4) Access the values from this static class whereevere you need them

5) Lycka till


Sally

Dave Lorde
April 1st, 1999, 05:01 AM
Use AfxGetApp(), which returns a pointer to the application object, and cast it to your derived class like this:


CMyApp* pMyApp = dynamic_cast (AfxGetApp());


Now you can access your derived application public members:


int value = pMyApp->GetValue();


Dave