更新时间:2022-05-15 15:32:10
这取决于你所说的属性...
如果您的意思是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 orWNDCLASS
structure then you'll needSet/GetWindowLongPtrPtr
or the 32 bit equivalent.
IF you mean the members of an MFC C++ object associated with a given window handle you can useCWnd::FromHandle
to get aCWnd
pointer from the associated window handle. However there has to be an MFC C++ object associated with the handle - i.e. you've created aCWnd
derived object, calledCreate
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 aCWnd
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.