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 

Problem with hatch pattern

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Shawn Thomas
Guest





PostPosted: Wed May 02, 2007 4:07 am    Post subject: Problem with hatch pattern Reply with quote



Hello all,

I am trying to display a rectangle on a TImage with a bsDiagCross
fill. I am painting the background of the image in white and then
trying to paint the rectangle, but the space between the lines stay
black.

var
TmpBrush : TBrush;
TmpRect : TRect;
begin
TmpBrush := TBrush.Create;
TmpBrush.Color := clWhite;
TmpBrush.Style := bsSolid;
AxImage.Canvas.Brush := TmpBrush;
TmpRect.Left := 0;
TmpRect.Top := 0;
TmpRect.Right := AxImage.Width;
TmpRect.Bottom := AxImage.Height;
// White background
AxImage.Canvas.FillRect(TmpRect);
TmpRect.Left := 10;
TmpRect.Top := 10;
TmpRect.Right := 40;
TmpRect.Bottom := 60;
TmpBrush.Color := ClRed;
TmpBrush.Style := bsDiagCross;
AxImage.Canvas.Brush := TmpBrush;
AxImage.Canvas.FillRect(TmpRect);
TmpBrush.Free;
end;

I Tried to SetBkColor(AxImage.Canvas.Handle, clWhite), but it doesn't
seem to help. What am I doing wrong?

Thanks,
Shawn

--
Back to top
David Ninnes
Guest





PostPosted: Wed May 02, 2007 4:43 am    Post subject: Re: Problem with hatch pattern Reply with quote



Try this,

var
TmpBrush : TBrush;
TmpRect : TRect;
begin
setBkMode(Canvas.Handle, TRANSPARENT);
TmpBrush := TBrush.Create;
TmpBrush.Color := clWhite;
TmpBrush.Style := bsSolid;
AxImage.Canvas.Brush := TmpBrush;
TmpRect.Left := 0;
TmpRect.Top := 0;
TmpRect.Right := AxImage.Width;
TmpRect.Bottom := AxImage.Height;
// White background
AxImage.Canvas.FillRect(TmpRect);

TmpRect.Left := 10;
TmpRect.Top := 10;
TmpRect.Right := 40;
TmpRect.Bottom := 60;
TmpBrush.Color := ClRed;
TmpBrush.Style := bsDiagCross;
AxImage.Canvas.Brush := TmpBrush;
SetBkColor(AxImage.Canvas.Handle, clWhite);
setBkMode(Canvas.Handle, TRANSPARENT);
AxImage.Canvas.FillRect(TmpRect);
TmpBrush.Free;
end;

SetBkMode is the incantation you need.

hth,
Dave
Back to top
Shawn Thomas
Guest





PostPosted: Thu May 03, 2007 12:10 am    Post subject: Re: Problem with hatch pattern Reply with quote



David Ninnes wrote:

Quote:

Try this,

var
TmpBrush : TBrush;
TmpRect : TRect;
begin
setBkMode(Canvas.Handle, TRANSPARENT);
TmpBrush := TBrush.Create;
TmpBrush.Color := clWhite;
TmpBrush.Style := bsSolid;
AxImage.Canvas.Brush := TmpBrush;
TmpRect.Left := 0;
TmpRect.Top := 0;
TmpRect.Right := AxImage.Width;
TmpRect.Bottom := AxImage.Height;
// White background
AxImage.Canvas.FillRect(TmpRect);

TmpRect.Left := 10;
TmpRect.Top := 10;
TmpRect.Right := 40;
TmpRect.Bottom := 60;
TmpBrush.Color := ClRed;
TmpBrush.Style := bsDiagCross;
AxImage.Canvas.Brush := TmpBrush;
SetBkColor(AxImage.Canvas.Handle, clWhite);
setBkMode(Canvas.Handle, TRANSPARENT);
AxImage.Canvas.FillRect(TmpRect);
TmpBrush.Free;
end;

SetBkMode is the incantation you need.

hth,
Dave

Dave,

Thanks for your response, that did the trick.

Regards,
Shawn

--
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics 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.