为什么GetSafeHwnd()在ActiveX控件中返回零? [英] Why does GetSafeHwnd() return zero in an ActiveX control?
问题描述
GetSafeHwnd()
获取Windows句柄,但不幸的是,该方法在运行时返回零。也许我在创建我的activex时设置错误的选项。如何创建一个无窗的activex可以操纵windows hanlde? 根据定义,无窗ActiveX控件没有窗口,并且作为其父对象的一部分呈现。如果要在控件中使用Windows消息,可以创建具有消息循环的工作线程,并处理任何消息。要有消息循环,你不需要一个窗口,只是线程。
或者,您可以通过更改其属性来使用窗口化的ActiveX控件。
I have developed a MFC Activex control which is windowless and invisible in runtime, while i assumed that basically an activex is a control that would manipulate a windows handle, i have used GetSafeHwnd()
to get windows handle, but unfortunately this method returns zero when it runs. maybe i had set wrong option when creating my activex. how i can create a windowless activex which could manipulate windows hanlde?
By definition, windowless ActiveX control doesn't have a window, and rendered as part of its parent. If you want to work with Windows messages in the control, you can create worker thread with a message loop, and handle any messages there. To have message loop, you don't need a window, just thread. This solution can be implemented in windowless control or in any COM component.
Alternatively, you can use windowed ActiveX control by changing its properties.
这篇关于为什么GetSafeHwnd()在ActiveX控件中返回零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!