没有SetActiveView的话,GetActiveView是会返回NULL的
把代码放在document里面,要更新界面的话用UpdateAllViews
把代码放在document里面,要更新界面的话用UpdateAllViews
解决方案 »
- RichEditView中使用RichEdit2.0A的问题
- 创建ATL工程的时候,选择的是不支持MFC, 现在要使用MFC 中的CMapStringToString , 怎么办? 如何设置为支持MFC. 我不会使用 STL 的 map ,而
- !!!!寻人启示!!!!(一个函数找不到,不知道是杂交的还是冒牌的)
- 堂堂一个卧虎苍龙得csdn,高手们都到那里去了??????????????????再发一铁,在线
- 请问如何从窗口handle得到进程handle
- 真是奇怪了,这到底是怎么回事?请教了
- com口的数量?
- 问一下窗体的各种尺寸问题,以及如何用GetSystemMetrics获得它们的尺寸?
- 史上最牛c++技术群 成立了 等待你的加盟52749842
- 网络蚂蚁的断点续传是怎样实现的?
- 如何模拟进程占用文件句柄,使其他进程无法读写或删除此文件
- MFC写的Player数据采集器器,打开创建Excel时提示找不到“Templates.xls”,求大神指导
访问应用程序的其它类 获得CWinApp:
-在CMainFrame,CChildFrame,CDocument,CView中直接调用AfxGetApp()或用theApp
-在其它类中只能用AfxGetApp() 获得CMainFrame:
-在CMinApp中用AfxGetMainWnd()或者m_pMainWnd
-在CChildFrame中可用GetParentFrame()
-在其它类中用AfxGetMainWnd() 获得CChildFrame:
-在CView中用GetParentFrame()
-在CMainFrame中用MDIGetActive()或GetActiveFrame()
-在其它类中用AfxGetMainWnd()->MDIGetActive()或AfxGetMainWnd()->GetActiveFrame() 获得CDocument:
-在CView中用GetDocument()
-在CChildFrame中用GetActiveView()->GetDocument()
-在CMainFrame中用
-if SDI:GetActiveView()->GetDocument()
-if MDI:MDIGetActive()->GetActiveView()->GetDocument()
-在其它类中
-if SDI:AfxGetMainWnd()->GetActiveView()->GetDocument()
-if
MDI:AfxGetMainWnd()->MDIGetActive()->GetActiveView()->GetDocument() 获得CView:
-在CDocument中 POSITION pos = GetFirstViewPosition();GetNextView(pos)
-在CChildFrame中 GetActiveView()
-在CMainFrame中
-if SDI:GetActiveView()
-if MDI:MDIGetActive()->GetActiveView()
-在其它类中
-if SDI:AfxGetMainWnd()->GetActiveView()
-if MDI:AfxGetMainWnd()->MDIGetActive()->GetActiveView()
不过要注意在doc中要取得view的指针C*View要注意类C*View声明的问题,
因为默认情况下,mfc在*View.h中已经包含了*Doc.h,如果在*Doc.h中包含
*View.h,就会引起嵌套包含问题,这样要在*Doc.h中加入 class C*View;
而在*Doc.cpp中加入 #include "*View.h" 这段话的意思应该懂的吧。
是因为这
if( !pView->IsKindOf(pClass) )
{
//AfxMessageBox( "Connot locate the View.");
return NULL;
}删了就行了!!