Solved

GetDocument() Question

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 …

740 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