How to make the form into fully transparent 32bit alpha?

前端 未结 2 1477
悲哀的现实
悲哀的现实 2021-01-16 10:37

i use to create a full transparent form, but the png and the 32bit image will not blend to the form and images is not properly displayed its trnsparency. i get the concept h

相关标签:
2条回答
  • 2021-01-16 10:44

    Seems that Andreas Hausladen stumbled upon a similar problem and has already implemented a solution: he rewrote TJvTransparentForm in the JVCL library.

    Even if you are not going to use that component directly you may gain some insight by studying the source.

    Here is the link to Andreas' article.

    0 讨论(0)
  • 2021-01-16 11:03

    If you want to use a PNG to control transparency you might want to look into "layered windows":

    • SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED);
    • UpdateLayeredWindow

    This allows you to have variable transparency accross the window, just as PNG allows! The problem is, controls on layered windows don't really work, I guess it's a Windows issue. My solution was to actually brake up the big window into multiple smaller windows, with all the controls on non-layered windows. This creates yet an other problem, because you now have multiple windows and you want them to move like a single window. The solution: implement your own algorithm for moving the window accross the screen and use:

    • BeginDeferWindowPos
    • DeferWindowPos
    • EndDeferWindowPos

    ... to move all windows at once, so the user has no idea she's looking at multiple windows! Finally, if you want to get fancy, you might want to look into SetWindowRgn: this allows you to create a window with a non-rectangular shape.

    P.S: Reading Andrea's link from Uwe Raabe, he's using the same technique, only he packaged it ready for action!

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