I put some picture onto my form, and I should put some other things
(button, combobox, etc) so I should group them. When I use TPanel and
TScrollBox that come with Delphi, the picture looks ugly because TPanel
or TScrollBox fill their area with the grey color.
Thanks in advance.
Edy
Hi, Edy
In order 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 the code of a transparent panel, I've been posting in this ng not
long ago:
_____________________________________________________
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
How about transparent ScrollBox? Do you have any example?
TIA
Edy
In article <3c151c7d_1@dnews>, serge_...@yahoo.com says...