Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Transparent Panel & ScrollBox

336 views
Skip to first unread message

Edy

unread,
Dec 6, 2001, 11:15:01 AM12/6/01
to
Hi, does anyone has transparent panel or scrollbox components?

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

serge gubenko

unread,
Dec 10, 2001, 3:34:43 PM12/10/01
to

"Edy" <e...@intouch.co.id> wrote in message
news:MPG.1679395f9...@newsgroups.borland.com...

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

Edy

unread,
Dec 12, 2001, 7:54:48 PM12/12/01
to
Thank you Serge, I'll try your code.

How about transparent ScrollBox? Do you have any example?


TIA
Edy

In article <3c151c7d_1@dnews>, serge_...@yahoo.com says...

0 new messages