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

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

问题描述

我可以使用哪些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屋!

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