WS_EX_TRANSPARENT - 这是什么实际上做? [英] WS_EX_TRANSPARENT - What does it actually do?

查看:1414
本文介绍了WS_EX_TRANSPARENT - 这是什么实际上做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目,我创建了一个表格由用户控制的不透明度。如果表单是完全透明的鼠标事件告吹(没有我的干预),否则我的形式来处理它们。

In my project, I create a form with the opacity controlled by the user. If the form was fully transparent the mouse events 'fell through' (without my intervention), otherwise my form handled them.

阅读的这个问题并重写CreateParams属性设置 WS_EX_TRANSPARENT 标记的窗体上,它现在可以让鼠标事件告吹当不透明度为任意值< 255

After reading this question and overriding the CreateParams property to set the WS_EX_TRANSPARENT flag on my form, it now allows mouse events to fall through when the opacity is any value <255.

这正是我想要的,但对我而言,我不明白为什么它的工作原理

This is exactly what I want, but it concerns me that I don't understand why it works.

从我读过,WS_EX_TRANSPARENT是为了使形式,偷位透明出现在它的Paint方法它下面的表格,因此:

From what I've read, WS_EX_TRANSPARENT is meant to make the form appear transparent by 'stealing bits' from the form below it in its Paint method, therefore:


  1. 我的形式和它的所有控件的Paint方法不应该叫吧?由于WS_EX_TRANSPARENT应该导致Windows覆盖他们,所以为什么它会影响输入处理,但不是我的格式的绘图?

  1. The Paint method of my form and all the controls in it should never be called, right? As WS_EX_TRANSPARENT should cause Windows to override them, so why does it affect input handling but not the drawing of my form?

不透明度应该对没有影响鼠标事件的处理,因为如果油漆被覆盖本地不透明度要不要紧,不是吗?

The opacity should have no impact on the handling of mouse events, as if Paint is being overridden the 'local' opacity should not matter, no?

莫非有人解释,这是什么标志的真的呢?它是如何工作的?

Could someone explain, what this flag really does? How does it work?

推荐答案

WS_EX_TRANSPARENT使你的事件(如鼠标点击)告吹你的窗口,除其他事项。透明度是一个单独的概念,它指示窗口管理器绘制的表格时要应用alphablending。这两件事情都没有关系,但是当你将它们结合起来,你让你在你的情况需要的效果。

WS_EX_TRANSPARENT makes your events (like mouse clicks) fall through your window, amongst other things. Opacity is a separate concept, it instructs window manager to apply alphablending when drawing your form. Those two things are not related, but when you combine them you get the effect you need in your case.

所以:


  1. 窗体的Paint方法通常称为因为它应该,不透明度无关吧。

  1. Paint method of your form is called normally as it should, opacity has nothing to do with it.

不透明度的确实的没有什么关系的鼠标事件,描述在第一个段落。

Opacity does not have anything to do with mouse events, as described in the first paragraph.

这篇关于WS_EX_TRANSPARENT - 这是什么实际上做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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