TList활용하기
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMyData=record
SAW_CODE:String;
FName:String;
end;
MyData=^TMyData;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MyList:TList;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var PMyData:MyData;
begin
Form2:=TForm2.Create(Application);
New(PMyData);
PMyData^.SAW_CODE:='최광배';
PMyData^.FName:=Form2.Name;
MyList.Add(Pointer(PMyData));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MyList:=TList.Create;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
MyList.Free;
MyList:=nil;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:Integer;
begin
For i:=MyList.Count-1 downto 0 do begin
if Application.FindComponent(MyData(MyList.Items[i])^.FName)=nil then
MyList.Delete(i);
end;
For i:=0 to MyList.Count-1 do begin
TForm(Application.FindComponent(MyData(MyList.Items[i])^.FName)).Caption:=MyData(MyList.Items[i])^.FName;
TForm(Application.FindComponent(MyData(MyList.Items[i])^.FName)).Show;
end;
end;
end.
'Delphi Tip > 컴포넌트' 카테고리의 다른 글
[Controls] EDIT에 숫자만 입력받기 (0) | 2021.11.02 |
---|---|
TXMLDocument를 이용한 XML로딩방법 (0) | 2021.11.01 |
TEdit 다음 포커스 이동하기 (0) | 2021.10.28 |
TEdit 숫자만 입력받기 (0) | 2021.10.27 |
TdateEdit 날짜 요일 구하기 (0) | 2021.10.26 |
댓글