如何使用DLL在对话框文本框中显示Window属性 [英] how to display Window property inside Dialog Text box using DLL

查看:99
本文介绍了如何使用DLL在对话框文本框中显示Window属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,专家
我的问题是
我不明白如何通过使用该窗口的句柄访问窗口属性,例如其名称,类和文本,该属性包含在其中.???
我可以找到所选窗口的句柄和标题
但无法在对话框控件中显示它,它仅显示在消息框中.
请帮助
在高级中感谢...

Hi Experts
My problem is that
I am not able to understand that how to access window property like its name, class and text contain inside it by using handle of that window.???
I am able to find its handle and its caption of that selected window
but am not able to display it inside dialog box control, it is displaying only on message box.
Plz help
Thanks in advanced...

推荐答案

这里是问题所在:您为什么没有指向MFC CWnd实例的指针(或其他任何指针)使用)?

当然,当CWnd安装用于处理原始Windows消息的Window过程时,它应该在原始Windows API数据中保留"this"指针,这通常是由基于Windows API的UI库完成的.这是在具有OOP库的类实例和原始Window数据之间保持映射的方式. 但是-如果这是您的应用程序,则您已经有了该指针;如果不是这样的话-获取此指针没有帮助,因为您不能安全地将其强制转换为您可能假定的MFC类,因为没有任何东西可以保证该窗口是使用MFC构建的;和与您使用的版本相同的MFC.

另外,请务必理解,从任何MFC类派生的Windows API注册的Window类都是两个绝对不同的东西.

现在,如果只需要窗口文本,则可以使用GetWindowText,请参见 http://msdn.microsoft.com/en-us/library/ms633584(v = vs.85).aspx [
Here is the problem: how come you don''t have a pointer to the instance of MFC CWnd (or whatever you use)?

Certainly, as CWnd installs it''s Window procedure for handling raw Windows messages, it should keep "this" pointer in raw Windows API data, which is usually done by UI libraries build on Windows API. This is the way to keep mapping between the class instance with OOP-library and raw Window data. But — if this is your application, you already have this pointer; if not — getting this pointer is not helpful, because you cannot safely cast it to the MFC class you might assume, as nothing can guarantee that the window was build using MFC; and MFC of the same version as you use.

Also, do understand that Windows API registered Window class of the class derived from any MFC class are two absolutely different things.

Now, if you need just the window text, you can use GetWindowText, see http://msdn.microsoft.com/en-us/library/ms633520%28v=vs.85%29.aspx[^].


To extract other information from the raw Window handle, use the function GetWindowLong, see http://msdn.microsoft.com/en-us/library/ms633584(v=vs.85).aspx[^]. Potentially the pointer to the instance of the UI library class can be stored at the index GWL_USERDATA, but nothing can guarantee you any certain interpretation of this pointer or valid type cast you can use if this is not your application.

—SA


这篇关于如何使用DLL在对话框文本框中显示Window属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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