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]