MFC编程SetDlgItemText的问题

jluhongfeng 2013-03-19 04:24:48
我在成员函数中有这样一句,
SetDlgItemText(IDC_EDIT2,s);
IDC_EDIT2是一个Edit Control的ID,s是一个char型的数组,但是编译的时候老是提示我下面的错误,不知道为什么?请各位高人指点啊。错误如下:
error C2660: 'SetDlgItemTextA' : function does not take 2 arguments
...全文
766 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
scg08 2013-05-23
  • 打赏
  • 举报
回复
缺少句柄,一般在主线程中就是2个参数,但是在线程中需要加上句柄,在线程中建议用PostMessage。希望对楼主有用。
赵4老师 2013-03-20
  • 打赏
  • 举报
回复
::SetDlgItemText The SetDlgItemText function sets the title or text of a control in a dialog box. BOOL SetDlgItemText( HWND hDlg, // handle of dialog box int nIDDlgItem, // identifier of control LPCTSTR lpString // text to set ); Parameters hDlg Identifies the dialog box that contains the control. nIDDlgItem Identifies the control with a title or text that is to be set. lpString Pointer to the null-terminated string that contains the text to be copied to the control. Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError. Remarks The SetDlgItemText function sends a WM_SETTEXT message to the specified control. --------------- CWindow::SetDlgItemText BOOL SetDlgItemText( int nID, LPCTSTR lpszString ); SeeSetDlgItemText in the Win32 SDK. Remarks Changes a control’s text. --------------- CWnd::SetDlgItemText void SetDlgItemText( int nID, LPCTSTR lpszString ); Parameters nID Identifies the control whose text is to be set. lpszString Points to a CString object or null-terminated string that contains the text to be copied to the control. Remarks Sets the caption or text of a control owned by a window or dialog box. SetDlgItemText sends aWM_SETTEXT message to the given control.
jluhongfeng 2013-03-19
  • 打赏
  • 举报
回复
引用 楼主 jluhongfeng 的回复:
我在成员函数中有这样一句, SetDlgItemText(IDC_EDIT2,s); IDC_EDIT2是一个Edit Control的ID,s是一个char型的数组,但是编译的时候老是提示我下面的错误,不知道为什么?请各位高人指点啊。错误如下: error C2660: 'SetDlgItemTextA' : function does not take 2 ar……
我看书里的例子也是直接用这两个参数呀,第二个参数也是直接把数组名作为参数传进去
jimette 2013-03-19
  • 打赏
  • 举报
回复
error C2660: 'SetDlgItemTextA' : function does not take 2 arguments 不接受两个参数 函数原型 BOOL WINAPI SetDlgItemText( _In_ HWND hDlg, _In_ int nIDDlgItem, _In_ LPCTSTR lpString );
starytx 2013-03-19
  • 打赏
  • 举报
回复
我记得是这样用吧 GetDlgItem(IDC_EDIT2)->SetDlgItemText(s);
未注销 2013-03-19
  • 打赏
  • 举报
回复
看看参数啊,应该为LPCTSTR类型,so……

64,649

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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