Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2010
Visual Studio
Visual C++
MFC
MFC Classes
CFrameWnd Class
 CFrameWnd::GetActiveView
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
Visual Studio 2010 - Visual C++
CFrameWnd::GetActiveView

Call this member function to obtain a pointer to the active view (if any) attached to a frame window (CFrameWnd).

CView* GetActiveView( ) const;

A pointer to the current CView. If there is no current view, returns NULL.

This function returns NULL when called for an MDI main frame window (CMDIFrameWnd). In an MDI application, the MDI main frame window does not have a view associated with it. Instead, each individual child window (CMDIChildWnd) has one or more associated views. The active view in an MDI application can be obtained by first finding the active MDI child window and then finding the active view for that child window. The active MDI child window can be found by calling the function MDIGetActive or GetActiveFrame as demonstrated in the following:

Visual C++
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->GetMainWnd();

// Get the active MDI child window.
CMDIChildWnd *pChild = (CMDIChildWnd*)pFrame->GetActiveFrame();

// or CMDIChildWnd *pChild = pFrame->MDIGetActive();

// Get the active view attached to the active MDI child window.
CMyView *pView = (CMyView*)pChild->GetActiveView();

Header: afxwin.h

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker