TIA =)
Cheers,
Nick Barrett
PS: Maybe I should be posting to borland.public.delphi.graphics?
Hi, Nick
Seems your question (or similar) was discussed in this ng not long ago.
Anyway, to paint a panel with transparent color you should override its
Paint method, draw it there to the buffer bitmap, repaint a part of the
Parent window and then Copy this BitMap to the main Canvas by using a
TCanvas.CopyBrush function.
Here's an example:
_____________________________________________________
TMyTransparentPanel = class(TPanel)
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure Paint; override;
end;
{...}
procedure TMyTransparentPanel.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if not (csDesigning in ComponentState)
then Params.ExStyle:=Params.ExStyle or WS_EX_TRANSPARENT;
end;
procedure TMyTransparentPanel.Paint;
var
XBitMap: TBitMap;
XOldDC: HDC;
XRect: TRect;
begin
{This panel will be transparent only in Run Time}
if (csDesigning in ComponentState)
then inherited Paint
else begin
XRect:=ClientRect;
XOldDC:=Canvas.Handle;
XBitMap:=TBitMap.Create;
try
XBitMap.Height:=Height; XBitMap.Width:=Width;
Canvas.Handle:=XBitMap.Canvas.Handle;
inherited Paint;
RedrawWindow(Parent.Handle, @XRect, 0,
RDW_ERASE or RDW_INVALIDATE or
RDW_NOCHILDREN or RDW_UPDATENOW);
finally
Canvas.Handle:=XOldDC;
Canvas.BrushCopy(XRect, XBitMap, XRect, Color);
XBitMap.Free;
end;
end;
end;
______________________________________________________
Best regards, Serge Gubenko
Sorry about that.
Thank you very much for your help =)
Cheers,
Nick Barrett