//虛線樣式
虛線樣式表:
var
g: TGPGraphics;
p: TGPPen;
begin
g := TGPGraphics.Create(Canvas.Handle);
p := TGPPen.Create(MakeColor(255,255,0,0),3);
g.DrawLine(p, 11, 11, 333, 11); {實線}
p.SetDashStyle(DashStyleDashDot); {設置虛線樣式}
g.DrawLine(p, 11, 33, 333, 33); {繪制任何形狀都是可以的}
p.Free;
g.Free;
end;
//自定義虛線樣式
var
g: TGPGraphics;
p: TGPPen;
const
dash: array[0..3] of Single = (5,2,15,10); {虛線樣式數組, 數組維數大小任意}
begin
g := TGPGraphics.Create(Canvas.Handle);
p := TGPPen.Create(MakeColor(255,255,0,0),3);
g.DrawLine(p, 11, 11, 333, 11);
p.SetDashPattern(@dash, Length(dash)); {設置虛線}
g.DrawLine(p, 11, 33, 333, 33);
p.Free;
g.Free;
end;