• Advertisement
Sign in to follow this  

how to get doc or view object ?

This topic is 4359 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

in MFC, I know doc and view is created in ProcessShellCommand with CSingleDocTemplate. but I wanna get current view pointer so that I can hide it by ShowWindow(getView(), SW_HIDE);

Share this post


Link to post
Share on other sites
Advertisement
You want to use your MainFrame class (CMDIFrameWnd or CSDIFrameWnd) to issue the ShowWindow() call.

You can do something like the following:

#include "mainfrm.h"
CMainFrame *mainFrm = (CMainFrame*)AfxGetMainWnd();
pMainFrame->ShowWindow(SW_HIDE);

Share this post


Link to post
Share on other sites
Well, from the CMainFrame class:


#include "MyApp Doc.h"
#include "MyApp View.h"

// ... Somewhere in code
CMyAppView *pView = (CMyAppView*) GetActiveView();



From another class:


#include "MainFrm.h"

#include "MyApp Doc.h"
#include "MyApp View.h"

// ... Somewhere in code
CMainFrame *pFrame = (CMainFrame*) AfxGetMainWnd();
CMyAppView *pView = (CMyAppView*) pFrame->GetActiveView();

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement