获取对话框中的文本 [英] Get the text within a dialog box

查看:34
本文介绍了获取对话框中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用哪些 Windows API 函数来获取对话框中的文本?例如,如果我有一个错误消息对话框的句柄,我如何获得显示的错误消息?

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 函数(请参阅 http://msdn.microsoft.com/en-us/library/ms645489(VS.85).aspx)

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆