Solved

GetDocument() Question

Posted on 2003-11-22
3
741 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
repeatSeparator  java  challenge 13 56
Error on moodle after upgrade 3 107
iSeries FTP Exit Program 8 114
Fibonacci challenge 11 84
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: 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.
This video discusses moving either the default database or any database to a new volume.

743 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

13 Experts available now in Live!

Get 1:1 Help Now