Solved

CMyApp to get access to CMyView?

Posted on 1998-11-05
2
576 Views
Last Modified: 2013-11-20
I have a SDI CFormView app.

I want to add a item on the menu that will run a function
that I have declared in CMyView. (ie CMyView::Run)

The class wizard inserted a function (CMyApp::OnRun) in CMyApp that will get run everytime the menu item is selected.

How do call the function CMyView::Run from within
CMyApp::OnRun()?

Is there some way to get a pointer to the view from
within the CMyView class (like AfxGetView())?

let me know if you need more clarification.
thanks
0
Comment
Question by:vinny5
2 Comments
 
LVL 7

Accepted Solution

by:
psdavis earned 50 total points
ID: 1324257
Sure.  Here's my code that I used once to make it work!

   CVisaApp* pApp = CVisaApp::GetApp( );

// If the view is already opened, then just go to it!

   CCountryView* pCountryView = NULL;

   POSITION posTemplate = pApp->GetFirstDocTemplatePosition( );
   
   while( posTemplate )
   {
      CDocTemplate* pTemplate = (CDocTemplate*) pApp->GetNextDocTemplate( posTemplate );

      POSITION posDocument = pTemplate->GetFirstDocPosition( );
     
      while( posDocument )
      {
      // If we found a document of this type, then we're already done.  Just activate it!

         CDocument* pDocument = pTemplate->GetNextDoc( posDocument );

         if( pDocument->IsKindOf( RUNTIME_CLASS( CSignatureDoc )))
         {
         // Now iterate all of the windows and activate the first one!

            POSITION posView = pDocument->GetFirstViewPosition( );

            if( posView )
            {
               CView* pView = pDocument->GetNextView( posView );

               ((CMDIChildWnd*) pView->GetParentFrame( ))->MDIActivate( );
            }

            return;
         }
         else if( pDocument->IsKindOf( RUNTIME_CLASS( CCountryDoc )))
         {
         // Now iterate all of the windows and activate the first one!

            POSITION posView = pDocument->GetFirstViewPosition( );

            if( posView )
            {
               pCountryView = (CCountryView*) pDocument->GetNextView( posView );
            }
         }

      }
   }
   
Phillip
0
 

Author Comment

by:vinny5
ID: 1324258
Great!  Thanks it works...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now