?
Solved

CWinApp::OnIdle - updating active doc

Posted on 1998-11-05
1
Medium Priority
?
423 Views
Last Modified: 2013-11-20
In a MDI app, I need to make updates to the active child document in the app's OnIdle() event.  How can I get a pointer to the active document from the app class?  And, most importantly, will I be able to call functions that I have added by subclassing CMDIChildWnd when I get the pointer to it.  Also, I'm not using doc/view.  MFC is confusing the hell out of me, so any help would be wonderful!
0
Comment
Question by:dolce
[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
1 Comment
 
LVL 1

Accepted Solution

by:
TheGrinch earned 200 total points
ID: 1324256
In your App class, GetMainWnd() returns a CWnd* pointer to your main window, so it needs to be cast...

   CMDIFrameWnd* mainwnd = (CMDIFrameWnd*)GetMainWnd();

Then, get the document with...

   CMyDocument* doc = (CMyDocument*)mainwnd->GetActiveDocument();

And get the view with...

   CMyView* view = (CMyView*)mainwnd->GetActiveView();

Get the child window with...

   CMDIChildWnd* child = (CMDIChildWnd*)view->GetParent();

You should be able to call the functions...

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

777 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