点结构Tpoint是delphi自带的类型,要注意和无类型指针Pointer区分开来!无类型指针笔记链接:https://www.cnblogs.com/168-h/p/14807404.html
procedure TForm1.Button1Click(Sender: TObject);
VAR
MYPoint:TPoint;
{點結構TPoint是Delphi自帶的類型,定義在Windows窗體:TPoint = Types.TPoint;然後是Types窗體的定義:
TPoint = packed record
X: Longint;
Y: Longint;
end; }
MYARR:array [0..2] OF TPoint; //結構體數組
I:Integer;
begin
MYPoint.X:=10;
MYPoint.Y:=100;
//ShowMessage(IntToStr(MYPoint.X));//10
//ShowMessage(IntToStr(MYPoint.Y));//100
ShowMessageFmt('X=%d,Y=%d',[MYPoint.X,MYPoint.Y]); //X=10,Y=100
Memo1.Clear;
for I:=Low(MYARR) to High(MYARR) DO
begin
MYARR[I].X:=I+1;
MYARR[I].Y:=I+2;
Memo1.Lines.Add(Format('%d的X=%d,Y=%d'+#13#10,[I,MYARR[i].X,MYARR[i].Y]));//#13是回車鍵,#13#10才是換行。
{ memo1的行如下:
0的X=1,Y=2
1的X=2,Y=3
2的X=3,Y=4
}
end;
end;