全部博文(788)
分类:
2008-11-05 09:42:18
DC : HDC;
DC := GetDC(0);
LineTo(DC,X,Y);
划一条与背景色相同的线
或者
Canvas.Pen.Mode := pmNotXor再划一条同样颜色的线
在Forms上、用蓝颜色、从P1(x1,y1)到P2(x2,y2)的直线的画法:
begin
canvas.pen.color:=clBlue;
Canvas.MoveTo(x1,y1);
Canvas.LineTo(x2,y2);
end;
如果要在在Form1的Image1组件上、用红颜色、从P1(x1,y1)到P2(x2,y2)的直线的画法:
begin
Image1.canvas.pen.color:=clred;
Image1.Canvas.MoveTo(x1,y1);
Image1.Canvas.LineTo(x2,y2);
end;
以上三个语句中重复出现的Image1.Canvas可以用With语句简化为:
begin
with image1.canvas do
begin
Pen.Color:=clRed;
MoveTo(x1,y1);
LineTo(x2,y2);
end;
end;