 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
az@hyliosoft.com Guest
|
Posted: Tue Mar 15, 2005 9:04 am Post subject: D7 - Custom Control - Toolbar and background |
|
|
Hi everyone,
I'm using D7 and I've created a control that derives a TCustomControl.
I'm painting the new control with a bitmap by using the canvas's
control.
I need to put a toolbar in that control. I'm setting the transparent
property of the toolbar to True because I want to see the parent
background.
But the problem is that I'm getting a black background for the toolbar
instead to see the parent background portion.
Can someone help me on this please?
Thanks!
Antony
|
|
| Back to top |
|
 |
Bill Bateman Guest
|
Posted: Thu Apr 07, 2005 7:20 am Post subject: Re: D7 - Custom Control - Toolbar and background |
|
|
Hello Antony,
Use the following code to draw a transparent image to the canvas first,
then draw everything else to that canvas after. It is working great
for me!
procedure DrawParentImage(Control: TControl; Dest: TCanvas);
var
SaveIndex: Integer;
DC: HDC;
Position: TPoint;
begin
with Control do
begin
if Parent = nil then
Exit;
DC := Dest.Handle;
SaveIndex := SaveDC(DC);
{$IFDEF DFS_COMPILER_2}
GetViewportOrgEx(DC, @Position);
{$ELSE}
GetViewportOrgEx(DC, Position);
{$ENDIF}
SetViewportOrgEx(DC, Position.X - Left, Position.Y - Top, nil);
IntersectClipRect(DC, 0, 0, Parent.ClientWidth,
Parent.ClientHeight);
Parent.Perform(WM_ERASEBKGND, DC, 0);
Parent.Perform(WM_PAINT, DC, 0);
RestoreDC(DC, SaveIndex);
end;
end;
Bill
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|