Solved

Accessing Doc data from a dialog...

Posted on 1998-04-21
3
179 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
Comment Utility
Hi Salamander,

Would this work for you?

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


0
 
LVL 2

Expert Comment

by:SamratAshok
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

11 Experts available now in Live!

Get 1:1 Help Now