问题描述
我想要一个对点击透明的 HWND(即,将它们传递到下面的窗口).
I want an HWND that is transparent to clicks (i.e. passes them through to windows underneath).
起初我尝试了 WS_EX_TRANSPARENT 但它有各种重绘问题.下面的窗口最终会覆盖我的 HWND.
At first I tried WS_EX_TRANSPARENT but that has all sorts of redraw problems. Windows underneath end up drawing over my HWND.
我进行了一些搜索,发现了一个通过返回 HTTRANSPARENT 来响应 WM_NCHITTEST 的建议.这似乎有效,但 MSDN 声明它仅在下面的窗口在同一线程中时才能正常工作.搜索 HTTTRANSPARENT 出现了一些问题(http://www.virtualdub.org/blog/pivot/entry.php?id=147)
I did some searching and found a suggestion to respond to WM_NCHITTEST by returning HTTRANSPARENT. This seemed to work but MSDN states that it only works correctly when the windows underneath are in the same thread. Searching for HTTTRANSPARENT turned up some problems (http://www.virtualdub.org/blog/pivot/entry.php?id=147)
那么……还有其他想法吗?
So...any other ideas?
推荐答案
捕获所有鼠标消息并使用 PostMessage 将它们转发到底层窗口.
Catch all mouse messages and forward them to the underlying window with PostMessage.
这篇关于Win32:如何使 HWND 对点击透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!