Solved

Retrieving a document pointer

Posted on 1999-01-11
5
237 Views
Last Modified: 2010-04-02
I am trying to retrieve a pointer to the active document in my application from my CMainFrame class (which is derived from CMDIFrameWnd).
I am calling GetActiveDocument() but all Im getting is a NULL pointer. Any suggestions?
0
Comment
Question by:rangers99
  • 3
5 Comments
 
LVL 4

Accepted Solution

by:
nil_dib earned 60 total points
ID: 1181900
The documents in you MDI are associated with your CChildFrame objects (derived from CMDIChildWnd)!
So no Doc is related to your CMainFrame and you get a NULL pointer!
Call GetActiveDocument() in your CMDIChildWnd derived class and you will get the pointer to the doc attached with this class.
0
 
LVL 2

Expert Comment

by:AdrianBrown
ID: 1181901
From what I remember you need to have a CMDIChildWnd as well.  I think these are then all registered with an CMultiDocTemplate that controls the whole process.  Apart from that Ive mainly used a app wizard to generate the code for a basic mdi.  If ya want that let me know and ill email it to you
0
 

Author Comment

by:rangers99
ID: 1181902
Thanks a lot!
0
 

Author Comment

by:rangers99
ID: 1181903
Thanks a lot!
0
 

Author Comment

by:rangers99
ID: 1181904
Thanks a lot!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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 days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

749 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