Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Accessing Doc data from a dialog...

Posted on 1998-04-21
3
Medium Priority
?
195 Views
Last Modified: 2013-11-20
I need to to display certain data pertaining to my CDocument class in a dialog box(let's say CDlg), and didn't think it was kosher to actually send the pointer to the CDocument object from, say the CView class where I created the CDlg.  To make a long story short, is there a quick way to get a pointer to the current document object in any location?  I know how to do this from the CMainFrame object, but is there some easy was to do it from ANY object?
0
Comment
Question by:salamander
3 Comments
 
LVL 2

Accepted Solution

by:
rayb earned 150 total points
ID: 1301050
Hi Salamander,

Would this work for you?

CDocument *pDoc= AfxGetMainWnd()->GetActiveDocument();


0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 1301051
There is a way to obtain a document pointer from MFC. But if you do not want to
pass pointer because of C++ philosophy, getting pointer from MFC is just a longer
(and painful) way to violate the same rules.

With that in mind, I would either edit the constructors of dialogbox to accomodate just the
specific values or  add a post-construction function to pass data to dialog box.
(you will have to probably call it before showing dialog)

You can access document pointer using App object : DocTemplate List : Document List.

Look for functions like GetNextDocument, GetNextDocTemplate and of course AfxGetApp
in help

Since you have access to App object everywhere. you have access to this everywhere.


0
 

Author Comment

by:salamander
ID: 1301052
Thanks for the help.  I actually need to do this quickly so, forgive me, I am going to fudge a little on my creed of data-hiding and object-oriented political-correctness.  Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

926 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