unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormMouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
FPoints: TList;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure FreeListMem(List: TList);
var
I: Integer;
Item: Pointer;
begin
for I := List.Count-1 downto 0 do
begin
Item := List.Items;
Dispose(Item);
List.Items := nil;
end;
List.Clear;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FPoints := TList.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FPoints.Free;
end;
procedure TForm1.FormMouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
var
P: PPoint;
begin
New(P);
P^.X := X;
P^.Y := Y;
FPoints.Add(P);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
PointArr: array of TPoint;
I: Integer;
P: PPoint;
begin
SetLength(PointArr, FPoints.Count);
for I := 0 to FPoints.Count-1 do
begin
P := FPoints.Items;
PointArr.X := P^.X;
PointArr.Y := P^.Y;
end;
FreeListMem(FPoints)
//用完记得释放内存
end;
end.