文本框的事件处理程序问题:GetDlgItemText(IDC_ECODE,ecode,15)和MessageBox()的使用!

firecityplans 2009-06-02 12:37:39
本人初学一个程序。为文本框添加一个事件处理程序。如下代码:
其中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
...全文
27 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaojunjun1202 2009-06-09
  • 打赏
  • 举报
回复
楼上正解
  • 打赏
  • 举报
回复
所有字符串前面加上_T(),比如MessageBox(_T("Hello world!"));

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧