Solved

GetDocument() Question

Posted on 2003-11-22
3
754 Views
Last Modified: 2013-11-20
CmfcDoc* CFrontEnd::GetDocument() const
{
//      ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CmfcDoc)));
      return (CmfcDoc*)m_pDocument;
}

CmfcDoc* pDoc=(CmfcDoc*) GetDocument();

I wanna get some data items from CDoument class while not from CView class, how do I achieve this? Thanks
Jack
0
Comment
Question by:luckie
  • 2
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9802384
From any place of CView-derived class you can use GetDocument function to access the document class:

void CFrontEnd::AnyFunction()
{
    GetDocument()->SomeFunction();  // access document functions and members
}
0
 

Author Comment

by:luckie
ID: 9802584
Hi Alex,
Mine is not a CView-derived. Could I do the same with any generic classes?Thanks
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 50 total points
ID: 9803120
From any place if SDI application you can access document class by the following way:

CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
CMyView *pView = (CMyView *) pFrame->GetActiveView();
CMyDocument* pDocument = pView->GetDocument();
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 140
fizzArray  challenge 1 96
withoutTen challenge 14 131
how to use laptop or pad camera in vb.net windows application 2 86
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 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