WS_EX_TRANSPARENT - What does it actually do?

后端 未结 2 1597
难免孤独
难免孤独 2020-12-03 20:00

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), otherw

相关标签:
2条回答
  • 2020-12-03 20:28

    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.

    So:

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

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

    0 讨论(0)
  • 2020-12-03 20:32

    It makes the window invisible to mouse events, or -as Microsoft puts it- it doesn't obscure the windows below. I believe it doesn't actually steal pixels from the windows below, but Windows itself will probably blend those two pictures together, using the level of transparancy you supplied.

    Transparent windows can be useful for showing some progress or a splash screen, but you'll have to program a way to close them, because just click the X won't work since the mouse click will pass through it.

    So not only does it change the level of visual transparency, but it modifies the behaviour too. I wonder where you would have read otherwise.

    [edit]

    Don't Windows in C# just have an opacity property?

    0 讨论(0)
提交回复
热议问题