Search the web
Sign In
New User? Sign Up
delphigames · Discussion of game programming in the Delphi development environment.
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
How to make real transparency (with control)?   Message List  
Reply | Forward Message #7585 of 7611 |
Re: [DelphiGames] Re: How to make real transparency (with control)?

Ani_Silvia <ani_silvia@...> wrote: "You can
get background using Themes unit"
Do you know how? (I know that can be done with a few lines, but for
now I don't know anything for themes unit)
UxTheme.pas it is the Same from SoftGems (Mike Lischke' ); document.write(
addy_text67334 ); document.write( '' ); //-->\n ) and Delphi.
Check the source too, you may find help on the web for this unit.

//------------------------------------------------------------------------------\
----------------------------------------
// DrawThemeParentBackground()
// - used by partially-transparent or alpha-blended
// child controls to draw the part of their parent
// that they appear in front of.
//
// hwnd - handle of the child control
// hdc - hdc of the child control
// prc - (optional) rect that defines the area to be
// drawn (CHILD coordinates)
//------------------------------------------------------------------------------\
----------------------------------------

var
DrawThemeParentBackground: function(hwnd: HWND; hdc: HDC; prc: PRECT):
HRESULT; stdcall;

HDC (DeviceContext) is the Canvas.Handle
HWND (WindowHandle) is the TWinControl.Handle

I don't remember exactly how but you can add a canvas to any WinControl, maybe
look in the VCL code.
Also you can use WinAPI to get the Window DC based on the window handle
GetWindowDc or similar ...
"you can also get image from Panel or Form"
Can you share a code that do this? If I can get snapshot of what is
under my control before it is painted on top, I can do everithing :)

Use a Form and a Image (You can use TBitmap or something else) and paint the
image with what the Form has on it even other child controls such as TButton:

Image1.Canvas.CopyRect(Image1.ClientRect, Canvas, Image1.ClientRect); // Quite
simple don't you think ?

This code works if use with a Form, could be used with Panel if you add a canvas
or use Winapi. However it has a drawback, you need the snapshot before you do
any drawing of your own otherwise you get your draw also.

Regions are good because they eliminate fully transparent parts. We
have Alpha transparency on window controls, but it is not per pixel.
And you are right the best way for flicker free control is using
double buffering.

At some point i wrote my own XP buttons using regions but no alpha support, they
were faster than XPs own buttons even if i used the same technique for drawing
them but i didn't support per pixel alpha as XP does, problem was i needed a
snapshot before my drawing was done or i should blend with the parent color.





---------------------------------
Never miss a thing. Make Yahoo your homepage.

[Non-text portions of this message have been removed]




Mon Dec 17, 2007 10:58 am

rbaprog
Offline Offline
Send Email Send Email

Forward
Message #7585 of 7611 |
Expand Messages Author Sort by Date

Hi guys, I'm trying to do control with real transparency – when you put a picture under it you must see the picture trough transparent pixels. Can you give...
ani_silvia
Offline Send Email
Dec 12, 2007
8:13 am

Ani_Silvia <ani_silvia@...> wrote: Hi guys, I'm trying to do control with real transparency – when you put a picture...
rbaprog
Offline Send Email
Dec 13, 2007
9:38 pm

Hi rbaprog, I've read very carefully your post (2 times). Here are some observations: "You can get background using Themes unit" Do you know how? (I know that...
ani_silvia
Offline Send Email
Dec 17, 2007
10:01 am

Ani_Silvia <ani_silvia@...> wrote: "You can get background using Themes unit" Do you know how? (I know that can be done...
rbaprog
Offline Send Email
Dec 17, 2007
9:04 pm

Thank you, thank you very much rbaprog!!! Here I will share what I have found and hope this will be helpful. DrawThemeParentBackground works fine on Delphi7...
ani_silvia
Offline Send Email
Dec 19, 2007
8:49 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help