Sign in to follow this  
derek7

how to get doc or view object ?

Recommended Posts

derek7    100
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
Premandrake    175
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
TFS_Waldo    146
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this