Solved

CMyApp to get access to CMyView?

Posted on 1998-11-05
2
581 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA "SendKeys" Syntax for Multiple Keystrokes 7 133
either24  challenge 19 107
Line meaning 9 96
moto 4g phone enable finger print 4 72
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

737 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