在对话框中获取文本 [英] Get the text within a dialog box
问题描述
我可以使用哪些Windows API函数在对话框中获取文本?例如,如果我有一个错误消息对话框的 handle ,如何获取显示的错误消息?
What Windows API function can I use to get text within a dialog? For example, if I had the handle of an error message dialog, how could I get the displayed error message?
推荐答案
如果我正确理解了您的问题,那么您的问题就很容易了.从Visual Studio 工具菜单中打开 Spy ++ .然后按 Ctrl + F 会出现一个对话框,用于查找窗口.拖曳将查找器工具"放在要从中读取文本的对话框内的控件上;查看窗口的属性,您需要的是控件ID"字段.
If I correctly understand your question, your problem is very easy. Open Spy++ from the Visual Studio Tools menu. Then press Ctrl + F to receive a dialog for finding windows. Drag & drop the "Finder tool" on the control inside the dialog box from which you want to read the text; look at properties of the window, the field "Control ID" is what you need.
如果您具有对话框窗口(HWND hDlg)的句柄,则应使用GetDlgItemText
函数(请参阅
If you have a handle of the Dialog Window (HWND hDlg) you should use the GetDlgItemText
function (see http://msdn.microsoft.com/en-us/library/ms645489(VS.85).aspx)
UINT GetDlgItemText(HWND hDlg,
int nIDDlgItem,
LPTSTR lpString,
int nMaxCount
);
阅读文字.作为nIDDlgItem
参数,您应该放置控件的标识符.这是您使用Spy ++找到的值.
to read the text. As a nIDDlgItem
parameter you should place the identifier of the control. It is the value which you have found using Spy++.
这篇关于在对话框中获取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!