Hi there
Try something like:
uses WinTypes, WinProcs, WinCrt;
type
TPtArray = array[0..0] of TPoint;
PPtArray = ^TPtArray;
function AskPointsCount: word;
var
NumPts: word;
begin
{A function you create to get}
{an idea of how many points the}
{user wants}
write('How many points? :');
readln(NumPts);
AskPointsCount := NumPts;
end;
procedure GetSinglePoint(var APoint: TPoint);
begin
{A function you create to get}
{all points user wants, one at a time}
write('Pt.X: ');
readln(APoint.X);
write('Pt.Y: ');
readln(APoint.Y);
end;
function GetPoints(var PtArray: PPtArray): word;
var
NumItems: word;
i: word;
begin
NumItems := AskPointsCount;
GetPoints := 0;
GetMem(PtArray, SizeOf(TPoint) * NumItems);
if PtArray = nil then exit;
for i := 0 to NumItems -1 do
GetSinglePoint(PtArray^[i]);
GetPoints := NumItems;
end;
procedure DisposePoints(var PtArray: PPtArray; NumPts: word);
begin
FreeMem(PtArray, (NumPts * SizeOf(TPoint)));
PtArray := nil;
end;
var
PtArray: PPtArray;
NumPts: word;
SomeDC: hDC;
i: word;
begin
NumPts := GetPoints(PtArray);
clrscr;
for i := 0 to numpts -1 do
begin
writeln('Your selections are: ');
writeln('Point: ', i, ' ', PtArray^[i].X, ':',
PtArray^[i].Y);
end;
if PtArray <> nil then
begin
SomeDC := GetDC(SomeWindow);
{Where somewindow is a valid window handle}
Canvas.Polygon(SomeDC, PtArray^, NumPts);
{Not being a Delphi user, I assume this is what your}
{call looks like. If an array is required instead of a}
{pointer to an array, then use ...Polygon(PtArray^)}
{This is the Polygon method used in TPW/BP}
DisposePoints(PtArray, NumPts);
ReleaseDC(SomeWindow, SomeDC);
end
else
begin
writeln('Not able to allocate memory');
{Unable to get pointer to array}
end;
end.
Hop this helps.
--
Regards
James Burroughs
Internet: Burro...@Telkom09.Telkom.Co.Za