简体   繁体   English

整个表格的Hittest透明性

[英]Hittest transparency for an entire form

Is it possible for the entire bounds of a form to be hittest transparent without adjusting the visibility of the form? 表单的整个边界是否可以在不调整表单可见性的情况下达到最透明?

I am using a user32 api call to WindowFromPoint in order to find the control under the mouse. 我正在对WindowFromPoint使用user32 api调用,以便在鼠标下找到控件。 In some circumstances I would like to ignore the existance of a child form that floats in front of the main form (or another child form), but keep this form to ignore visible. 在某些情况下,我想忽略浮动在主表单(或另一个子表单)前面的子表单的存在,但保持此表单忽略可见。

Setting the Opacity of the form to ignore to 0 will successfully cause the hittest to pass straight through it, but the form obviously is invisible, and I'd prefer it to remain visible. 将表单的“不透明度”设置为“ 0”将成功地使Hittest直接通过它,但是表单显然是不可见的,我希望它保持可见。

Since this child form can have any arbitrary number of controls on it, is there a way for this form intercept all WM_NCHITTEST messages going to child controls on the form so that I can return hittest transparency for each control? 由于此子窗体上可以具有任意数量的控件,因此该窗体是否有办法拦截所有发送到该窗体上子控件的WM_NCHITTEST消息,以便我可以为每个控件返回hittest透明性? The controls contained on the form are arbitrary so I am unable to modify them internally. 表格中包含的控件是任意的,因此我无法在内部进行修改。

You are looking for the WS_EX_TRANSPARENT Windows Style. 您正在寻找WS_EX_TRANSPARENT Windows样式。

This answer gives a good-enough explanation. 这个答案给出了很好的解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM