更新时间:2023-10-03 18:06:52
CEdit
不是 ATL 类.命名空间 ATLControls
来自哪里?有一个具有此名称的 WTL 类,从中获取文本很容易:
CEdit
is not an ATL class. Where the namespace ATLControls
comes from? There is a WTL class with this name and getting text from it is easy:
ATLASSERT(Edit.IsWindow()); // Make sure the control holds a handle
CString sWindowText;
Edit.GetWindowText(sWindowText);
GetWindowText
方法来自 ATL 并且封装了 GetWindowTextLength
和 GetWindowText
API.后一篇 MSDN 文章也有一段代码片段展示了典型用法.
The method GetWindowText
is coming from ATL however and wraps GetWindowTextLength
and GetWindowText
API. The latter MSDN article also has a code snippet showing typical usage.
既然您提到 IsWindow
对您不起作用,那么最可能的问题是您的编辑控件包装类变量没有实际控件的句柄,因此从无到有获取文本不可能.
Since you mention that IsWindow
does not work for you, the most likely problem is that your edit control wrapper class variable just does not have a handle of a real control, and hence getting text from nothing is impossible.