Главная страница | назад





Article #17724: How do I use Paths and Geometric Pens?

 Question and Answer Database
FAQ2724D.txt How do I use Paths and Geometric Pens?
Category :Windows API
Platform :All
Product :All 32 bit
Question:
How do I use Paths and Geometric Pens?
Answer:
You will need to call the Windows API function ExtCreatePen() to
create a geometric pen style, and use the Canvas.Handle property to
use the Windows Path functions.
Example:
procedure TForm1.Button1Click(Sender: TObject);
var
lb : TLogBrush;
begin
lb.lbStyle := BS_SOLID;
lb.lbColor := RGB(255, 0, 0);
lb.lbHatch := 0;
Form1.Canvas.Pen.Handle :=
ExtCreatePen(PS_GEOMETRIC or
PS_INSIDEFRAME or
PS_ENDCAP_SQUARE or
PS_JOIN_BEVEL,
20,
lb,
0,
nil);
BeginPath(Form1.Canvas.Handle);
Form1.Canvas.MoveTo(100, 30);
Form1.Canvas.LineTo(200, 100);
Form1.Canvas.LineTo(300, 30);
EndPath(Form1.Canvas.Handle);
StrokePath(Form1.Canvas.Handle);
Form1.Canvas.Pen.Width := 1;
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99