程序工具栏上的“关于……”菜单项(ID号为IDD_ABOUTBOX)不能用(灰色),于是,我在CAppview里添加了成员函数以处理该菜单上的COMMAND消息:
void CAppView::OnAboutbox()
{
CAboutDlg about;
about.DoModal();
}
结果出现下面这样的问题,疑惑~~
error C2065: 'CAboutDlg' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'about'
error C2065: 'about' : undeclared identifier
error C2228: left of '.DoModal' must have class/struct/union type
初学VC,望多指教
void CAppView::OnAboutbox()
{
CAboutDlg about;
about.DoModal();
}
结果出现下面这样的问题,疑惑~~
error C2065: 'CAboutDlg' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'about'
error C2065: 'about' : undeclared identifier
error C2228: left of '.DoModal' must have class/struct/union type
初学VC,望多指教
XXXX.h包含CAboutDlg的声明
在MFC自动创建的程序中,“关于……”菜单的ID号为ID_APP_ABOUT,“关于”对话框资源ID则为IDD_ABOUTBOX
MFC将CAboutDlg的类定义放在App.cpp中,在该类的定义中建立了该类与“关于”对话框资源的关联:
enum { IDD = IDD_ABOUTBOX };
MFC在App.cpp中建立了消息映射:
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
所以只要是将“关于……”菜单的ID号和“关于”对话框资源的ID改动了,就会产生以上错误,解决办法就是重新建立以上CAboutDlg类与“关于”对话框资源的关联 和 消息映射。注意是在App.cpp中,在CAppView中添加成员函数只会使问题更糟(就想我上面做的那样)。若以上分析有任何问题,望不吝指正!
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}