Solved

Accessing Doc data from a dialog...

Posted on 1998-04-21
3
184 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
[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
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

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

623 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