Solved

CWinApp::OnIdle - updating active doc

Posted on 1998-11-05
1
418 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 50 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

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

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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.

733 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