Condividi tramite


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;

Return Value

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

Remarks

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:

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();

Requirements

Header: afxwin.h

See Also

Concepts

CFrameWnd Class

CFrameWnd Members

Hierarchy Chart

CFrameWnd::SetActiveView

CFrameWnd::GetActiveDocument