 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Shawn Thomas Guest
|
Posted: Wed May 02, 2007 4:07 am Post subject: Problem with hatch pattern |
|
|
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
|
Posted: Wed May 02, 2007 4:43 am Post subject: Re: Problem with hatch pattern |
|
|
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
|
Posted: Thu May 03, 2007 12:10 am Post subject: Re: Problem with hatch pattern |
|
|
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 |
|
 |
|
|
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
|
|