Solved

Retrieving a document pointer

Posted on 1999-01-11
5
225 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

867 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

22 Experts available now in Live!

Get 1:1 Help Now