文本框的事件处理程序问题:GetDlgItemText(IDC_ECODE,ecode,15)和MessageBox()的使用!
本人初学一个程序。为文本框添加一个事件处理程序。如下代码:
其中IDC_ECODE为文本框的变量。
void CMyFirstApplicationView::OnEnKillfocusEcode()
{
// TODO: 在此添加控件通知处理程序代码
char ecode[15];
GetDlgItemText(IDC_ECODE,ecode,15);
if( strlen(ecode) == 0 )
{
MessageBox( "The Employee Code can not be blank.Please enter an Employee Code" );
CEdit *code;
code = ( CEdit* )GetDlgItem(IDC_ECODE);
code->SetFocus();
}
}
但在编译时出现了如下错误:
1>正在编译...
1>MyFirstApplicationView.cpp
1>e:\studyvc\vcnet2005\ch03\myfirstapplication\myfirstapplication\myfirstapplicationview.cpp(106) : error C2664: 'int CWnd::GetDlgItemTextW(int,LPTSTR,int) const' : cannot convert parameter 2 from 'char [15]' to 'LPTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>e:\studyvc\vcnet2005\ch03\myfirstapplication\myfirstapplication\myfirstapplicationview.cpp(109) : error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [65]' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
还请指教,不知是不是头文件的问题还是什么其它问题。刚刚接触VC++。NET2005