Solved

CMyApp to get access to CMyView?

Posted on 1998-11-05
2
578 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 95
Host to IP 7 78
VBA "SendKeys" Syntax for Multiple Keystrokes 7 108
java ^ examples 8 65
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 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

12 Experts available now in Live!

Get 1:1 Help Now