程序的流程是这样的:
1.在对话框中动态创建按钮
2.按钮中的响应事件是创建一个窗口(继承自CFrameWnd)
3.在窗口中加入一个视图,视图是继承自CFormView
其中(1)、(2)项都已解决了,问题出在(3)项中,我是在CMyFrameWnd::OnCreateClient中用如下语句创建视图的,但是出错了,不知道何解???
CRuntimeClass* pNewViewClass;
pNewViewClass = RUNTIME_CLASS(CMyForm);
pContext.m_pNewViewClass = pNewViewClass;
出错的提示:
error C2065: 'IDD_MYFORMVIEW' : undeclared identifier (IDD_MYFORMVIEW是资源,我明明在Dialog中创建了,真奇怪)
error C2057: expected constant expression
error C2228: left of '.m_pNewViewClass' must have class/struct/union type Error executing cl.exe.或者要实现第三步,哪位大哥有代码了,谢谢!!!!main.exe - 3 error(s), 0 warning(s)
1.在对话框中动态创建按钮
2.按钮中的响应事件是创建一个窗口(继承自CFrameWnd)
3.在窗口中加入一个视图,视图是继承自CFormView
其中(1)、(2)项都已解决了,问题出在(3)项中,我是在CMyFrameWnd::OnCreateClient中用如下语句创建视图的,但是出错了,不知道何解???
CRuntimeClass* pNewViewClass;
pNewViewClass = RUNTIME_CLASS(CMyForm);
pContext.m_pNewViewClass = pNewViewClass;
出错的提示:
error C2065: 'IDD_MYFORMVIEW' : undeclared identifier (IDD_MYFORMVIEW是资源,我明明在Dialog中创建了,真奇怪)
error C2057: expected constant expression
error C2228: left of '.m_pNewViewClass' must have class/struct/union type Error executing cl.exe.或者要实现第三步,哪位大哥有代码了,谢谢!!!!main.exe - 3 error(s), 0 warning(s)
解决方案 »
- win32 创建非模态对话框的问题
- 能否从JPG流直接生成AVI格式的视频文件
- 最后21分了:请教DLL的共享数据段
- 还是CPropertyPage类变量的共享问题
- vc调用matlab动态链接库时,引入库“libmx.lib,libmat.lib,libmatlb.lib,libmmfile.lib,multiplyDll.lib”打不开?
- 将自定义资源(比如GIF)加到工程里,URL该如何写?????
- 50分问一个鼠标消息的问题。
- 请问,2000下面怎么读写并行端口?
- 请教VC的学习方法
- 急急急!如何制作一个支持名字服务的程序?或自己实现。只有这么多分了。
- _ConnectionPtr 到底是对象还是指针啊。
- 一些简单的问题
IDR_MAINFRAME 这个资源一定要有, 菜单 工具条之类的,
CYourDoc
CMainFrame
CYourView
一定要作好,也可以从别的项目拷贝过来
CYourApp::InitInstance()
{
...
SetRegistryKey(_T("应用程序向导生成的本地应用程序")); // 添加下面的代码 , 可以从别的项目拷贝过来 CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME, // 注意这个资源要有 菜单。
RUNTIME_CLASS(CYourDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CYourView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
......
}// 在单击消息里添加代码
void CYourDlg::OnBnClickedButton1()
{
CCommandLineInfo cmdInfo;
AfxGetApp() -> ParseCommandLine(cmdInfo);
if (!AfxGetApp() -> ProcessShellCommand(cmdInfo))
return ;
AfxGetApp() -> m_pMainWnd -> ShowWindow (SW_SHOW) ;
AfxGetApp() -> m_pMainWnd -> UpdateWindow () ;
}你的对话框 关闭时 m_pMainWnd 也将关闭。我认为还是应该 建立一个 DOC/View 项目 ,
然后在m_pMainWnd -> ShowWindow (SW_SHOW) ;
之前显示一个对话框,比较自然。
pDocTemplate = new CMultiDocTemplate(IDR_ABC4TYPE,
RUNTIME_CLASS(CABC4Doc),
RUNTIME_CLASS(CMyFrame), // 自定义 MDI 子框架
RUNTIME_CLASS(CABC4View));
if (!pDocTemplate)
{
MessageBox ("Error! -----Create DocTemplate !") ;
return ;
}
m_pDoc = (CABC4Doc*) pDocTemplate -> CreateNewDocument () ;
if ( !m_pDoc) return ;
m_pMyFrame = (CMyFrame*) pDocTemplate -> CreateNewFrame (m_pDoc, this) ;
if ( !m_pMyFrame) return ;
m_pMyFrame -> ShowWindow (SW_SHOW) ;
m_pMyFrame -> UpdateWindow () ;
这个注释 是从 vc 自动生成的代码 拷贝 时带上去的, CMyFrame 是自己定义的
从CFrameWnd 继承
加上include "resource.h"就行了斑主给我结贴吧!!!
我的分数要回来呀!!