获取对话框中的文本

编程入门 行业动态 更新时间:2024-10-06 06:44:51
本文介绍了获取对话框中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

更多推荐

[db:关键词]

本文发布于:2023-04-18 04:03:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/928353.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   对话框中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!