看一下这个(TList的帮助)
procedure TForm1.FormButton1Click(Sender: TObject);type
PMyList = ^AList;
AList = record
I: Integer;
C: Char;
end;var MyList: TList;
ARecord: PMyList;
B: Byte;
Y: Word;
begin
MyList := TList.Create;
try
New(ARecord);
ARecord^.I := 100;
ARecord^.C := 'Z';
MyList.Add(ARecord); {Add integer 100 and character Z to list}
New(ARecord);
ARecord^.I := 200;
ARecord^.C := 'X';
MyList.Add(ARecord); {Add integer 200 and character X to list} { Now paint the items onto the paintbox}
Y := 10; {Variable used in TextOut function} for B := 0 to (MyList.Count - 1) do
begin
ARecord := MyList.Items[B];
Canvas.TextOut(10, Y, IntToStr(ARecord^.I)); {Display I}
Y := Y + 30; {Increment Y Value again}
Canvas.TextOut(10, Y, ARecord^.C); {Display C}
Y := Y + 30; {Increment Y Value}
end; { Cleanup: must free the list items as well as the list }
for B := 0 to (MyList.Count - 1) do
begin ARecord := MyList.Items[B];
Dispose(ARecord);
end;
finally
MyList.Free;
end;
end;
procedure TForm1.FormButton1Click(Sender: TObject);type
PMyList = ^AList;
AList = record
I: Integer;
C: Char;
end;var MyList: TList;
ARecord: PMyList;
B: Byte;
Y: Word;
begin
MyList := TList.Create;
try
New(ARecord);
ARecord^.I := 100;
ARecord^.C := 'Z';
MyList.Add(ARecord); {Add integer 100 and character Z to list}
New(ARecord);
ARecord^.I := 200;
ARecord^.C := 'X';
MyList.Add(ARecord); {Add integer 200 and character X to list} { Now paint the items onto the paintbox}
Y := 10; {Variable used in TextOut function} for B := 0 to (MyList.Count - 1) do
begin
ARecord := MyList.Items[B];
Canvas.TextOut(10, Y, IntToStr(ARecord^.I)); {Display I}
Y := Y + 30; {Increment Y Value again}
Canvas.TextOut(10, Y, ARecord^.C); {Display C}
Y := Y + 30; {Increment Y Value}
end; { Cleanup: must free the list items as well as the list }
for B := 0 to (MyList.Count - 1) do
begin ARecord := MyList.Items[B];
Dispose(ARecord);
end;
finally
MyList.Free;
end;
end;
解决方案 »
- 求教,导出到Excel的问题
- 两个图片叠加,如何透过上面图片的部分区域看到下面的图片?
- Turbo Experlor系列是可以进行商业开发的。
- 如何捕捉或禁止indy的ftp组件的弹出错误信息
- 有没有像CAD一样的画矢量图的VCL,急用!!
- 请问QUERY和ADOQUERY有何区别,各有什么好处,什么时候用哪个比较好?
- 请问各位大虾如果要向需要显示的窗体中传递参数,有几种方法?各方法有何不同?(急)
- 请教高手:ADOConnection 连接问题 ...请多多指教,在线等...
- 菜鸟SOS
- 请来指点一下,我这个动态生成的sql,为什么查不到记录谢谢
- 用delphi6.0做网页好用吗?听说delphi6.0远程登录数据库(sql2000)很方便,有谁用过吗?
- 关于C程序移植到Delphi的问题?请大家帮忙!
MyRecord = record
i : integer;
j : integer;
end;
RecordArrays = array of MyRecord;
//PRecArr = ^RecordArrays;procedure SendRecords(Var a : RecordArrays);
我不知道你为什么非得要传指针,传一个数组不就解决问题了吗?
要用指针就回到c++中去,
在Delphi中少用指针!
传不进去是因为类型不匹配,你得统一定义类型,如:
type
Myarray = array of integer;
var
a,b: array of integer;
c : array of integer;
d : Myarray;
e : Myarray;
begin
setlength(a,5);
....
....
b := a; //正确;
d := e;//正确; c := a;//错误,类型不匹配;
d := a;//错误,类型不匹配;
d := c;//错误,类型不匹配;
end; delphi对类型的检查特别严格,根本不象c++中那样灵活,当然这样一来隐性的错误就少多了!