AnnGetPointCount example for Delphi
// This is an example for the following methods and properties
// AnnGetPointCount method, AnnGetPointX method, AnnGetPointY method
// and Point Property
//In the OnAnnDrawn event, this example checks to see if the annotation object is a polygon.
//If it is a polygon,
//the example gets the number of points that define the object;
//then it gets the Xpoints and YPoints and displays them in a message box.
procedure TForm1.LEADAnn1AnnDrawn (hObject: L_HANDLE);
var
nType: Integer;
a: Integer;
nPoints: Longint; //number of points in the object
msg: String;
XPoints: TANNPOINTS;
YPoints: TANNPOINTS;
begin
nType:= LEADAnn1.AnnGetType (hObject);
if (nType = ANNOBJECT_POLYGON ) then //Is the object a polygon?
begin
ShowMessage ('Object is a Polygon');
nPoints:= LEADAnn1.AnnGetPointCount(hObject); //get the number of points
XPoints:= LEADAnn1.AnnGetPointX (hObject); //get the X coordinates
YPoints:= LEADAnn1.AnnGetPointY (hObject); //get the Y coordinates
msg:= '(';
for a:= 1 to nPoints do
begin
msg:= msg + '{' + FloatToStr (XPoints.Point[a - 1]^.x) + ',' + FloatToStr(YPoints.Point [a - 1]^.y) + '}';
end;
msg:= 'The Polygon"s ' + IntToStr(nPoints) + ' points are:' +Chr(13)+ msg + ')';
ShowMessage (msg);
XPoints.Free ();
YPoints.Free ();
end;
LEADAnn1.AnnTool:= ANNTOOL_SELECT;
end;