我想把30多个各种各样的Form(数据库的输入表单)存储在一个数组里面,用户选取不同的表单时程序弹出不同的输入窗口。
我尝试过将TForm作为数组元素,但是好像不行;
我又试了将THandle作为数组元素,但是不知道怎么用Handle来Show Form!!
希望大侠们多多指教!!
我尝试过将TForm作为数组元素,但是好像不行;
我又试了将THandle作为数组元素,但是不知道怎么用Handle来Show Form!!
希望大侠们多多指教!!
cbWindows: TCombobox; With cbWindows.Items do
if IndexOfObject(TObject(Form.handle))=-1 then
begin
if NewCaption='' then
AddObject(Form.Caption,TObject(Form.handle))
else
AddObject(NewCaption,TObject(Form.handle));
cbWindows.ItemIndex := Count - 1;
end;
uses
Windows, Messages, SysUtils, Variants, Classes, Controls, ExtCtrls, StdCtrls, Forms;type
TMyClass = Class(TComponent)
private
FList: TList;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published end;implementation{ TMyClass }constructor TMyClass.Create(AOwner: TComponent);
begin
inherited;
FList := TList.Create;
FList.Add(Pointer(TForm.Create(Self)));
// ...
//显示这个FORM时,这样调用:
TForm(FList[0]).Show;
end;destructor TMyClass.Destroy;
var
i: Integer;
begin
for i := 0 to FList.Count - 1 do
TFrom(FList[i]).Free;
Flist.Free;
inherited;
end;end.