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.
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.
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:
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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…