我在button1Click下建了n个窗体,现在我想遍历这此窗体对它进行设置,我怎样才能找到它呢。
用component[i].ClassName=TForm1找不到。
我现在是在新建一个窗体时用数组保存它的指针,但觉得麻烦。有没有更好的方法,请高手指教。
用component[i].ClassName=TForm1找不到。
我现在是在新建一个窗体时用数组保存它的指针,但觉得麻烦。有没有更好的方法,请高手指教。
解决方案 »
- 多线程POST时,验证码同步,如何实现
- 最基本的问题..
- 哪位大哥救命啊
- ★★★★★★★★★★★★ 几个函数给大家,不知道的UP一下 ★★★★★★★★★★★★
- 急阿!请问在Delphi中如何使用Corba?各位大侠请进!
- delphi新手必看——《提问的智慧》
- 有经验者救救我,ado+dbgrid控件的问题?
- delphi中怎么样才能格式化字串(同C++中)
- 关于ADOQuery中使用Delete语句执行错误的问题
- 在DBGrid上执行Query1.Locate定位时,如何让带蓝色背景的选择随游标一起绑定定位
- 在ADOQuery中用insert语句加入日期型值的问题
- 关于dxgrid的打印问题
unit Main;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ComCtrls,Unit2, StdCtrls;type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
Main1: TMenuItem;
Sub1: TMenuItem;
StatusBar1: TStatusBar;
procedure FormCreate(Sender: TObject);
procedure Main1Click(Sender: TObject);
procedure Sub1Click(Sender: TObject);
private
{ Private declarations }
SubMain:TForm2;
public
{ Public declarations }
SubCount:integer;
SubWindows:array [0..20] of TControl; //最多打开21个子窗口
procedure SetWindows(WindowCount,SubHeight,SubWidth:integer); //设置子窗口
procedure SetLeftWindows();//设置左边主窗口
procedure DelSubWindows(DelWindow:TControl); //删除子窗口
end;var
Form1: TForm1;implementationuses Unit3;{$R *.dfm}procedure TForm1.DelSubWindows(DelWindow:TControl);
var
i,j:integer;
begin
DelWindow.Free;
SubCount:=SubCount-1;
if DelWindow.Top<>0 then
i:=Round(DelWindow.Top/(ClientHeight/(SubCount+1)))
else
i:=0;
for j:=i to SubCount do
begin
SubWindows[j]:=SubWindows[j+1];
end;
if SubCount<>0 then
SetWindows(SubCount,Round((ClientHeight-StatusBar1.Height-4)/SubCount)-1
,Round(ClientWidth/3)-5);
end;procedure TForm1.SetLeftWindows();
begin
if SubCount>0 then
SubMain.Width:=ClientWidth-4
else
SubMain.Width:=Round(ClientWidth*2/3);
end;procedure TForm1.SetWindows(WindowCount,SubHeight,SubWidth:integer);
var
i,j:integer;
begin
j:=0;
for i:=0 to WindowCount-1 do
begin
SubWindows[i].Top:=j;
SubWindows[i].Left:=Round(ClientWidth*2/3);
SubWindows[i].Width:=SubWidth;
SubWindows[i].Height:=SubHeight;
j:=j+SubHeight;
end;
{for i:=0 to SubCount-1 do
begin
memo1.Lines.Add(SubWindows[i].Name);
end;
}
end;procedure TForm1.FormCreate(Sender: TObject);
begin
SubCount:=0;
end;procedure TForm1.Main1Click(Sender: TObject);
begin
SubMain:=TForm2.Create(nil);
SubMain.Top:=0;
SubMain.Left:=0;
SubMain.Height:=ClientHeight-StatusBar1.Height-4;
SetLeftWindows();
SubMain.Show;
end;procedure TForm1.Sub1Click(Sender: TObject);
var
sub:TForm3;
begin
sub:=TForm3.Create(nil);
SubWindows[subCount]:=Sub;
inc(subCount);
SetLeftWindows();
SetWindows(SubCount,Round((ClientHeight-StatusBar1.Height-4)/SubCount)-1
,Round(ClientWidth/3.0)-5);
Sub.Show;
end;end.
begin
if application.FindComponent('Form1') is TForm1 then showmessage('1');
for i:=0 to application.ComponentCount-1 do
if application.Components[i].ClassType=TForm1 then showmessage('2');
end;
fm:=Tform1.create(self)
for i:= to ComponentCount-1 do
beginend;
------------------------------>改
fm:=Tform1.create(application)
for i:=0 to application.ComponentCount-1 do
if application.Components[i].ClassType=TForm1 then showmessage('2');
end;
fm:=Tform1.create(self)
fm.name='Form1';
if application.FindComponent('Form1') is TForm1 then showmessage('1');
for i:= to self.ComponentCount-1 do
beginend;
我这样写为什么会不行呢,
var ff: Tform2;
i:integer;
begin
ff:=Tform2.Create(self);
for i:=0 to self.ComponentCount-1 do
if self.Components[i].ClassType=Tform2 then showmessage('');
end;