2007年12月20日星期四

获得Cxxxview指针

前提: 在要获得view指针的.cpp文档中加入view.h及其头文档:
//----include header for CDbinfoView *pView
#include "ColorEdit.h"
#include "ColorStatic.h"
#include "ListCtrlStyled.h"
#include "DBinfoReg.h"
#include "dbinfo.h"
#include "dbinfoSet.h"
#include "ADOpaelogbuch.h"
#include "ABBruchDialog.h"
#include "DBinfoSmall.h"
#include "DBinfoListCt.h"
#include "dbinfoDoc.h"
#include "dbinfoView.h"
//----include header for CDbinfoView *pView

获得view指针:
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;

// 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.
CDbinfoView *pView = (CDbinfoView *) pChild->GetActiveView();


参考:
在MFC类中各种类的指针的获取和应用

没有评论: