![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
mfc CMainFrame怎么获取获取视图类指针,视图类怎么获取CMainFrame的指针
CMainFrame怎么获取获取视图类指针,视图类怎么获取CMainFrame的指针CMainFrame*pFrame=(CMainFrame*)AfxGetMainWn...
CMainFrame怎么获取获取视图类指针,视图类怎么获取CMainFrame的指针
CMainFrame* pFrame = ( CMainFrame* )AfxGetMainWnd();
CTest2View * pView= (CTest2View*)pFrame->GetActiveView();
为什么这样写会提示报错
c:\users\daoxin\desktop\test2\mainfrm.cpp(115) : error C2065: 'CTest2View' : undeclared identifier
c:\users\daoxin\desktop\test2\mainfrm.cpp(115) : error C2065: 'pView' : undeclared identifier
c:\users\daoxin\desktop\test2\mainfrm.cpp(115) : error C2059: syntax error : ')' 展开
CMainFrame* pFrame = ( CMainFrame* )AfxGetMainWnd();
CTest2View * pView= (CTest2View*)pFrame->GetActiveView();
为什么这样写会提示报错
c:\users\daoxin\desktop\test2\mainfrm.cpp(115) : error C2065: 'CTest2View' : undeclared identifier
c:\users\daoxin\desktop\test2\mainfrm.cpp(115) : error C2065: 'pView' : undeclared identifier
c:\users\daoxin\desktop\test2\mainfrm.cpp(115) : error C2059: syntax error : ')' 展开
1个回答
展开全部
你在mainfrm类里面肯定不行啊,视图类指针都还没有创建呢,咋 可以用啊。
追问
那要怎么办
追答
首先你在mainfrm类的哪个函数里获取其指针啊,感觉这样不够严谨,还有看你那个提示明显都是语法出错啊。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询