相同的代码也编译不过?
我先在VC6里面创建了一个MFC的项目,然后点击一个按钮获取当前系统的时间并显示出来:
// TODO: Add your control notification handler code here
CString str1;
CTime tm;
tm=CTime::GetCurrentTime();
str1= tm.Format("%Y年%m月%d日 %X");
this->GetDlgItem(IDC_EDIT1)->SetWindowText(str1);
this->SetWindowText("显示系统时间的简单窗体");
这个可以正常运行,得到的结果也是正确的。
然后我又在vs2008里面创建了一个MFC项目,窗体一样,控件的名字也一样,在相同的按钮下面写了相同的事件执行代码:
// TODO: Add your control notification handler code here
CString str1;
CTime tm;
tm=CTime::GetCurrentTime();
str1= tm.Format("%Y年%m月%d日 %X");
this->GetDlgItem(IDC_EDIT1)->SetWindowText(str1);
this->SetWindowText("显示系统时间的简单窗体");
结果编译的时候出现这两个错误:
错误 1 error C2664: “CWnd::SetWindowTextW”: 不能将参数 1 从“const char [23]”转换为“LPCTSTR” f:\c++程序\c++mfc\c++mfc\c++mfcdlg.cpp 187 c++mfc
错误 2 error C2664: “CWnd::MessageBoxW”: 不能将参数 1 从“const char [5]”转换为“LPCTSTR” f:\c++程序\c++mfc\c++mfc\c++mfcdlg.cpp 188 c++mfc
请问这是为什么?另外大家写MFC的时候用的是VC6还是用的VS呀?