use method from CMainFrm class fin CMyappApp::InitInstance method of an SDI app 
Author Message
 use method from CMainFrm class fin CMyappApp::InitInstance method of an SDI app

Hi all,

I made an MFC SDI app called Myapp using the wizzard. I automaticly get a
lot of files.I threw away the View, and  I added a couple of FormView
classes myself.

Because I want to switch between the views, in the CMainFrm I wrote a method
called switchView. This works fine, as long as I use it in this class
myself. But I allso want to use it from the CMainFrm class. I made it
already public, but I just don't know how to get a reference to the CMainFrm
from the CMyapp class.

So from the CMyapp::InitInstance() method I want to do something like:
theReferenceToTheMainFrm->switchView. But how do I get the Reference to the
MainFrm ?????

Can you help me out !

Many thanx,

LeNnArt



Mon, 03 Dec 2001 03:00:00 GMT  
 use method from CMainFrm class fin CMyappApp::InitInstance method of an SDI app
From your app object you can use
  CMainFrame* pFrame = (CMainFrame*)m_pMainWnd;

From anywhere else in the code you can use
  CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;



Mon, 03 Dec 2001 03:00:00 GMT  
 use method from CMainFrm class fin CMyappApp::InitInstance method of an SDI app
Lennart:

The m_pMainWnd member of CWinApp is a CWnd pointer to the main window. Just cast
it to your main window type.

HTH,

David Wilkinson

=====================

Quote:

> Hi all,

> I made an MFC SDI app called Myapp using the wizzard. I automaticly get a
> lot of files.I threw away the View, and  I added a couple of FormView
> classes myself.

> Because I want to switch between the views, in the CMainFrm I wrote a method
> called switchView. This works fine, as long as I use it in this class
> myself. But I allso want to use it from the CMainFrm class. I made it
> already public, but I just don't know how to get a reference to the CMainFrm
> from the CMyapp class.

> So from the CMyapp::InitInstance() method I want to do something like:
> theReferenceToTheMainFrm->switchView. But how do I get the Reference to the
> MainFrm ?????

> Can you help me out !

> Many thanx,

> LeNnArt



Mon, 03 Dec 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. calling an interface method from another method in the same class

2. vc6: View method to refer to App class member variable

3. Advice on using a class method to set its own property

4. MEMORY LEAK using CDaoRecordset Class and AddNew() method

5. Question about using ReadString() method in CArchive class

6. Using general API in MFC class methods

7. Using methods of differemt classes

8. using list class (clear method)

9. how can I call a method on a class using reflection

10. Using the AddStrip method on the ImageCollection class

11. class hierarchy for classes with only static methods

12. call from nested class method nonstatic of the class containing

 

 
Powered by phpBB® Forum Software