BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

D7 - Custom Control - Toolbar and background

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.components.writing
View previous topic :: View next topic  
Author Message
az@hyliosoft.com
Guest





PostPosted: Tue Mar 15, 2005 9:04 am    Post subject: D7 - Custom Control - Toolbar and background Reply with quote



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





PostPosted: Thu Apr 07, 2005 7:20 am    Post subject: Re: D7 - Custom Control - Toolbar and background Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.components.writing All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.