怎么申请多个memorystream实例?用于从数据库中取出多个图像流。(30分)

F

foxgirl

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,谢谢。
 
Z

zhhyoushen

Unregistered / Unconfirmed
GUEST, unregistred user!
var
foxgirl: Array of TStream;
想要多少都行[:D]
 
T

thx1180

Unregistered / Unconfirmed
GUEST, unregistred user!
是啊,想要多少就创建多少就行了。
 
F

foxgirl

Unregistered / Unconfirmed
GUEST, unregistred user!
哦,竟然忘记了数组[:D][:D][:D]
 
F

foxgirl

Unregistered / Unconfirmed
GUEST, unregistred user!
请问memorystream的实例如何初始化啊?
 
F

foxgirl

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFormbase.MTranBtn8Click(Sender: TObject);
var
ms: Array of TmemoryStream;
i:integer;
begin
ImageEnMView1.Clear;
for i:=0 to tinytable1.RecordCountdo
begin
ms:=TMemoryStream.Create;
tinytable1photo.SaveToStream( ms );
ms.Position:=0;
ImageEnMView1.SetImageFromStream( ImageEnMView1.AppendImage, ms );
end;
end;
请问对流数组实例如何初始化?上面的代码哪里出错了?老是提示出错
 
T

thx1180

Unregistered / Unconfirmed
GUEST, unregistred user!
type
PTmemoryStream = ^TmemoryStream;
var
ms: Array of PTmemoryStream;
SetLength(ms, SizeOf(PTmemoryStream)*tinytable1.RecordCount);
 
F

foxgirl

Unregistered / Unconfirmed
GUEST, unregistred user!
楼上的大哥:
procedure TFormbase.MTranBtn8Click(Sender: TObject);
var
ms: Array of PTmemoryStream;
i:integer;
begin
SetLength(ms, SizeOf(PTmemoryStream)*tinytable1.RecordCount);
ImageEnMView1.Clear;
for i:=0 to tinytable1.RecordCountdo
begin
ms:=PTMemoryStream.Create;//调试在这行出错object or class type required
tinytable1photo.SaveToStream( ms );
ms.Position:=0;
ImageEnMView1.SetImageFromStream( ImageEnMView1.AppendImage, ms );
end;
end;

type
PTmemoryStream = ^TmemoryStream;这个申明我放在单元前面的type中的。
 
T

thx1180

Unregistered / Unconfirmed
GUEST, unregistred user!
呵呵,既然数组是个指针列表了,当然要改一下啦:
ms^:=TMemoryStream.Create;//调试在这行出错object or class type required
tinytable1photo.SaveToStream( ms^ );
ms^.Position:=0;
 
F

foxgirl

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFormbase.MTranBtn8Click(Sender: TObject);
var
ms: Array of PTmemoryStream;
i:integer;
begin
SetLength(ms, SizeOf(PTmemoryStream)*tinytable1.RecordCount);
ImageEnMView1.Clear;
for i:=0 to tinytable1.RecordCountdo
begin
ms^:=TMemoryStream.Create;
tinytable1photo.SaveToStream( ms^ );
ms^.Position:=0;
ImageEnMView1.SetImageFromStream( ImageEnMView1.AppendImage, ms^ );
end;
end;

更正后,程序可以正常运行,其他功能也正常,但按这个procedure的按钮后,提示如下错误窗口:
Access violation at daaress 004af3a4 in module 'project1.exe',Write of address 00000000,按该窗口的"确定"后,程序继续运行,也就是说这个procedure没弄好,
不知该怎么改?多谢多谢。
 
T

thx1180

Unregistered / Unconfirmed
GUEST, unregistred user!
改这一句试试:
for i:=0 to tinytable1.RecordCount - 1do
 
F

foxgirl

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢thx1180,可惜我在有第二个回贴的时候过早的结贴了,分给完了,以后有机会再补起来[:D][:D][:D][:D]
 
Top Bottom