为什么GetSafeHwnd()在ActiveX控件中返回零? [英] Why does GetSafeHwnd() return zero in an ActiveX control?

查看:100
本文介绍了为什么GetSafeHwnd()在ActiveX控件中返回零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个MFC ActiveX控件,在运行时是无窗和隐形的,而我认为基本上activex是一个控制,将操纵一个窗口句柄,我使用 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屋!

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