怎么能使函数返回类型为TBitMap数组类型. ( 积分: 50 )

  • 主题发起人 主题发起人 xuanfeng_007
  • 开始时间 开始时间
X

xuanfeng_007

Unregistered / Unconfirmed
GUEST, unregistred user!
写了一个函数,可以转换N张图片,要把这N张图片作为返回值返回,在其他地方调用.直接返回 array of TBitMap,好象不行,请问有何好良策?
 
急需解决问题,在线等.给个思路也行啊.
 
帮你顶,接个分
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

type Tbmp=array[0..20] of TBitmap;

var
Form1: TForm1;

function showpicture: Tbmp;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
showpicture;
end;

function showpicture: Tbmp;
var
PBmp:Tbmp;
begin
Pbmp[0]:=TBitMap.Create;

end;

end.

我这样写,Pbmp[0]:=TBitMap.Create;会报错,弄不懂是怎么回事?帮我一下啊,急的不行了.
 
type
TBitmapArray = array of TBitmap;

function ShowPicture: TBitmapArray;
var
i : Integer;
begin
SetLength(Result, xxx);
for i := Low(Result) to High(Result) do
begin
Result := TBitmap.Create;
//....
end;
end;
 
用TList吧
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

bmpList:TList;

var
Form1: TForm1;

function showpicture: Tbmp;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
showpicture;
end;

function showpicture: TList;
var
Bmp:TBitmap;
begin
Result:=TList.Create;
Bmp:=TBitMap.Create;
List.Add(Bmp);
end;

end.
 
我用WinXP Delphi6
Pbmp[0]:=TBitMap.Create; 一句不会报错
 
感谢大家关注,以后有问题还的请教你们啊.虽然分不多,但是我以后会努力帮你门加分的.非常感谢各位.
 
后退
顶部