Solved

Accessing Doc data from a dialog...

Posted on 1998-04-21
3
181 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 50 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 119
Separate files macro - Errors on larger data set 18 71
VBA "SendKeys" Syntax for Multiple Keystrokes 7 108
MaxSpan challenge 9 96
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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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