I am having problems drawing different colored things on my component's
canvas. Basically I draw some squares defined by an array of points
(FPoints) which is turned into a TRect by PointRect.
I have one point defined as the selected one and I want that one to be
displayed differently. However changing the pen and brush does not seem
to have an effect as all squares (and joining lines) are drawn in the
same color.
I am using Delphi 5.
Below is the paint procedure.
--
type
TPolyLineSel = class(TGraphicControl)
{...}
protected
procedure Paint; override;
procedure TPolyLineSel.Paint;
var
i: integer;
tempBrush: TBrush;
tempPen: TPen;
begin
FWorkingOnCanvas := true;
if (csDesigning in ComponentState) then
Canvas.Rectangle(Rect(0, 0, Width, Height));
if assigned(OnPaintHandle) then
for i := 0 to Points do
OnPaintHandle(Self, i, FPoints[i].x, FPoints[i].y)
else
begin
with Canvas do
begin
tempBrush := Brush;
tempPen := Pen;
{ draw joining lines }
if FJoinLines then
begin
Pen := FLine;
if Points >= 0 then
MoveTo(FPoints[0].x, FPoints[0].y);
for i := 1 to Points do
LineTo(FPoints[i].x, FPoints[i].y);
{ draw closing line }
if (Points >= 0) and FClosePolygon then
LineTo(FPoints[0].x, FPoints[0].y);
end;
{ draw box handles }
for i := 0 to Points do
begin
if i = FSelectedPoint then
begin { selected box }
Pen := FSelectOutline;
Brush := FSelectFill;
end
else
begin { normal box }
Pen := FBoxOutline;
Brush := FBoxFill;
end;
Rectangle(PointRect(FPoints[i], FHandleOffset));
end;
Brush :=tempBrush;
Pen := tempPen;
end;
end;
FWorkingOnCanvas := false;
end;
Sent via Deja.com http://www.deja.com/
Before you buy.