views:

169

answers:

2

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 here but i cannot put button on it. all abject are invisible except the image backgound. by the way my compiler is delphi7 and D2009

+3  A: 

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.

Uwe Raabe
-1 for a link with no explanation.
Rob Kennedy
Please honor the license of JVCL. Even when copying source from it the license will stay intact.
ChristianWimmer
+1  A: 

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!

Cosmin Prund