我在SDI的主框架MainFrame中想获得CMyView的句柄,应该如何获得?
我用了下面的方法:
CMyView* pView;
pView=(CEnetVdoView*)((CFrameWnd*)AfxGetApp()->m_pMainWnd)->GetActiveView();
但在MainFrm.cpp中包含了#include "MyView.h"后就提示:
error C2143: syntax error : missing ';' before '*'
error C2501: 'CEnetVdoDoc' : missing storage-class or type specifiers
error C2501: 'GetDocument' : missing storage-class or type specifiers
是怎么回事,请高手指教?
我用了下面的方法:
CMyView* pView;
pView=(CEnetVdoView*)((CFrameWnd*)AfxGetApp()->m_pMainWnd)->GetActiveView();
但在MainFrm.cpp中包含了#include "MyView.h"后就提示:
error C2143: syntax error : missing ';' before '*'
error C2501: 'CEnetVdoDoc' : missing storage-class or type specifiers
error C2501: 'GetDocument' : missing storage-class or type specifiers
是怎么回事,请高手指教?
pView=(CEnetVdoView *)pMain->GetActiveView();
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CMy3View));由此,view是在mainframe之后建立,即在view对象还不存在,在mainframe里访问view对象不可能吧,建议在建立之后,运用静态全局view变量来访问
这是否说明了VC环境中已经将MainFrame、CView、CDocument的头文件互相包含了,他们的作用域互相交汇了,他们的关系是如何实现的?
我是在int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)中
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
语句后用到的CView;框架应该已经建立了巴!
error C2501: 'CEnetVdoDoc' : missing storage-class or type specifiers
error C2501: 'GetDocument' : missing storage-class or type specifiers
?
还少包含了文档类的头文件。