我定义了一个无模式话框,该对话框中有含有组合框,ID为ID_COMBO_LINESTYLE,然后生成了一个对话框类,这个对话框类的名称是:CLineStyleDlg,我在该类的CLineStyleDlg::OnSelchangeComboLinestyle() 函数中添加了获取框架窗口指针和视图窗口指针的代码,具体如下:
CMainFrame * pframe=(CMainFrame *)GetParent();//获取框架窗口指针
CTestdlgView * pview=(CTestdlgView *)pframe->GetActiveView();
//获取视图指针
而且我还在CLineStyleDlg类的实现文件中加了头文件:
#include "MainFrm.h"
#include "testdlgDoc.h" //文档类的定义
#include "testdlgView.h" //视图类的定义
但是编译出错:
F:\wjw\vc++\testdlg\LineStyleDlg.cpp(90) :
error C2065: 'CTestdlgView' : undeclared identifier
F:\wjw\vc++\testdlg\LineStyleDlg.cpp(90) :
error C2065: 'pview' : undeclared identifier
F:\wjw\vc++\testdlg\LineStyleDlg.cpp(90) : error C2059: syntax error : ')'请各位高手指点,谢谢!
CMainFrame * pframe=(CMainFrame *)GetParent();//获取框架窗口指针
CTestdlgView * pview=(CTestdlgView *)pframe->GetActiveView();
//获取视图指针
而且我还在CLineStyleDlg类的实现文件中加了头文件:
#include "MainFrm.h"
#include "testdlgDoc.h" //文档类的定义
#include "testdlgView.h" //视图类的定义
但是编译出错:
F:\wjw\vc++\testdlg\LineStyleDlg.cpp(90) :
error C2065: 'CTestdlgView' : undeclared identifier
F:\wjw\vc++\testdlg\LineStyleDlg.cpp(90) :
error C2065: 'pview' : undeclared identifier
F:\wjw\vc++\testdlg\LineStyleDlg.cpp(90) : error C2059: syntax error : ')'请各位高手指点,谢谢!
CTestdlgView * pview(CTestdlgView)pframe=GetActiveView();改为:
CtestdlgView * pview(CtestdlgView)pframe=GetActiveView();
但我的CTestdlgView是绝对没问题的,因为我是装了visual assist,而且我检查了很多遍。如果把T该为t,通不过visaul assist 的检查。
#include "testdlgView.h" 里的东西贴出来看看
CTestdlgView * pview=(CTestdlgView *)pframe->GetActiveView();
=================
问题可能出在第一句话上,某个字符没有被识别,已经提示你)出错了。重新写一遍看看,要不用下边方法。我这样用是好用的
void CTestDialog::OnButton1()
{
// TODO: Add your control notification handler code here
CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();
CTest2View* pView=(CTest2View*)pFrame->GetActiveView();}