视图类动态创建视图窗口

1 新建一个视图类CNewView(基类CFormView),构造函数需改成public,会自动添加资源IDD_NEWVIEW

2 实现CNewView的OnPaint

3 添加框架类目录项NewView,增加处理函数OnNewView,代码如下

	CView* pView = (CView*) new CNewView;
	CView* pOldView = GetActiveView();

	CCreateContext context;
	context.m_pCurrentDoc = GetActiveDocument();
	pView->Create(NULL,NULL,WS_CHILD,CFrameWnd::rectDefault,this,IDD_NEWVIEW,&context);
	pView->OnInitialUpdate();

	pView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
	SetActiveView(pView);
	pOldView->ShowWindow(SW_HIDE);
	pView->ShowWindow(SW_SHOW);

	RecalcLayout();


 

 

你可能感兴趣的:(视图类动态创建视图窗口)