如何在MFC中通过句柄设置窗口的属性 [英] How to set the properties of window by handle in MFC

查看:448
本文介绍了如何在MFC中通过句柄设置窗口的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在MFC中通过句柄设置窗口的属性。也就是说,我只知道手柄。所以,我想使用句柄来设置MFC中的属性。谢谢你的帮助。



我尝试过:



如何在MFC中按句柄设置窗口的属性。也就是说,我只知道手柄。所以,我想使用句柄在MFC中设置属性,我已经使用了很多方法来解决,但是失败了。谢谢您的帮助。我在网上等你的回答。

How to set the properties of window by handle in MFC. That is to say, I only know the handle. So , I want to use the handle to set the properties in MFC.Thank you for your help.

What I have tried:

How to set the properties of window by handle in MFC. That is to say, I only know the handle. So , I want to use the handle to set the properties in MFC, I I have used a lot of methods to solve, but failed. Thank you for your help. I I wait for your answer online.

推荐答案

这取决于你所说的属性...



如果您的意思是Win32窗口属性(窗口属性(Windows ) [ ^ ])然后你可以查看上面的参考资料。



如果你的意思是存储在Win32窗口结构中的数据或 WNDCLASS 结构然后你需要 Set / GetWindowLongPtrPtr 或32位等价物。



如果您指的是与给定窗口句柄关联的MFC C ++对象的成员,您可以使用 CWnd :: FromHandle 来获取来自关联窗口句柄的 CWnd 指针。但是必须有一个与句柄相关联的MFC C ++对象 - 即你已经创建了一个 CWnd 派生对象,名为 Create 在那上面或者使用了一些其他巴洛克式的MFC创建窗口的方法(或者对它进行子类化,但希望是另一个故事)。如果没有与窗口句柄关联的MFC对象,它似乎会起作用,但会出现严重错误。



因此,如果你需要一个 CWnd 稍后执行某些操作的指针在创建MFC对象时隐藏地址,并且不依赖于以后能够恢复它。
It depends what you mean by "properties"...

IF you mean Win32 window properties (Window Properties (Windows)[^]) then you can look at the reference above.

IF you mean data stored in the Win32 window structure or WNDCLASS structure then you'll need Set/GetWindowLongPtrPtr or the 32 bit equivalent.

IF you mean the members of an MFC C++ object associated with a given window handle you can use CWnd::FromHandle to get a CWnd pointer from the associated window handle. However there has to be an MFC C++ object associated with the handle - i.e. you've created a CWnd derived object, called Create on that or used some other baroque MFC method of creating the window (or subclassing it, but that's hopefully another story). If there's no MFC object associated with the window handle it'll appear to work but will go horribly wrong.

So the upshot of this lot is if you need a CWnd pointer to do something later stash the address when you create the MFC object and don't rely on being able to recover it later.


这篇关于如何在MFC中通过句柄设置窗口的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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