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

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

问题描述

我开发了一个 MFC Activex 控件,它在运行时是无窗口且不可见的,而我假设 Activex 基本上是一个可以操作 Windows 句柄的控件,我使用 GetSafeHwnd() 来获取windows 句柄,但不幸的是,此方法在运行时返回零.也许我在创建我的 activex 时设置了错误的选项.我如何创建一个可以操作 Windows hanlde 的无窗口 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?

推荐答案

根据定义,无窗口 ActiveX 控件没有窗口,并且作为其父级的一部分呈现.如果您想在控件中使用 Windows 消息,您可以创建带有消息循环的工作线程,并在那里处理任何消息.要拥有消息循环,您不需要窗口,只需线程即可.该解决方案可以在无窗口控件或任何 COM 组件中实现.

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.

或者,您可以通过更改其属性来使用窗口化 ActiveX 控件.

Alternatively, you can use windowed ActiveX control by changing its properties.

这篇关于为什么 GetSafeHwnd() 在 ActiveX 控件中返回零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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