注册 登录
编程论坛 VC++/MFC

求助!获取编辑框字符串

qldxsun 发布于 2011-06-15 23:43, 1077 次点击
求助!获取编辑框里输入的字符串
void CDDlg::OnChangeEdit1()
{
    // TODO: If this is a RICHEDIT control, the control will not
    // send this notification unless you override the CDialog::OnInitDialog()
    // function and call CRichEditCtrl().SetEventMask()
    // with the ENM_CHANGE flag ORed into the mask.
   
    // TODO: Add your control notification handler code here
    char str【】;
    GetDlgItem(IDC_EDIT1)->GetwindowText(str);
}
用mfc wizard建立了一个对话框,需要读入编辑框里输入的字符串并进行处理,红色部分报错
error C2039: 'GetwindowText' : is not a member of 'CWnd'
求指教啊!
msdn里对GetwindowText的解释
GetWindowText
The GetWindowText function copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application.

int GetWindowText(
  HWND hWnd,        // handle to window or control
  LPTSTR lpString,  // text buffer
  int nMaxCount     // maximum number of characters to copy
);
Parameters
hWnd
[in] Handle to the window or control containing the text.
lpString
[out] Pointer to the buffer that will receive the text.
nMaxCount
[in] Specifies the maximum number of characters to copy to the buffer, including the NULL character. If the text exceeds this limit, it is truncated.


怎么改呢?不会是我的vc6.0头文件有问题吧。。。

http://zhidao.baidu.com/question/203131774.html
百度有个解释,类似的,为什么改成他说的那样就行了?我的这个怎样改???

5 回复
#2
a3150102252011-06-16 17:49
CString str;
GetDlgItem(IDC_EDIT1)->GetWindowText(str); 你试一下
#3
hahayezhe2011-06-16 21:18
呵呵 调用完后 记得调用releasebuffer
#4
hahayezhe2011-06-16 21:19
代码没有错 Window要大写 后面要加
str.releasebuffer
#5
qldxsun2011-06-16 22:46
GetDlgItem(IDC_EDIT1)->GetWindowText(str);
写的时候没注意!谢谢大家!
#6
qldxsun2011-06-16 22:50
回复 4楼 hahayezhe
没有调用str.GetBuffer();也要release吗?
1