|
Тема |
Re: moga li pod DELPHI... lesno reshenie [re: PhantomAS] |
|
Автор |
TRN (член) |
|
Публикувано | 14.06.01 00:43 |
|
|
Опитай това.
unit Class1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
ListBox1: TListBox;
GroupBox1: TGroupBox;
ListBox3: TListBox;
Edit1: TEdit;
ComboBox1: TComboBox;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Const
FileName='OpiComp.txt';
procedure TForm1.FormCreate(Sender: TObject);
var
I:integer;
AStr,BStr,CStr:String;
Source: TComponent;
begin
if FileExists(FileName) then
with ListBox3.Items do
begin
LoadFromFile(FileName);
for I:=0 to Count-1 do
begin
AStr:=Strings;
BStr:=Copy(AStr,1,Pos(#9,AStr)-1);
AStr:=Copy(AStr,Pos(#9,AStr)+1,255);
CStr:=Copy(AStr,1,Pos(#9,AStr)-1);
AStr:=Copy(AStr,Pos(#9,AStr)+1,255);
if BStr='TEdit' then
begin
Source := FindComponent(CStr);
(Source as TEdit).Text:=AStr;
end;
if BStr='TComboBox' then
begin
Source := FindComponent(CStr);
(Source as TComboBox).Text:=AStr;
end;
end;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
procedure add(Sender:TObject);
begin
with ListBox3.Items do
if Sender.ClassNameIs('TEdit') then
Add((Sender as TEdit).ClassName+#9+
(Sender as TEdit).Name+#9+
(Sender as TEdit).Text)
else
if Sender.ClassNameIs('TComboBox') then
Add((Sender as TComboBox).ClassName+#9+
(Sender as TComboBox).Name+#9+
(Sender as TComboBox).Text);
end;
var
I:integer;
begin
ListBox3.Clear;
for I:=0 to ComponentCount-1 do
Add(Components);
ListBox3.Items.SaveToFile(FileName);
end;
end.
object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 144
Top = 152
Width = 185
Height = 177
Caption = 'Panel1'
TabOrder = 1
object ListBox1: TListBox
Left = 32
Top = 64
Width = 121
Height = 97
ItemHeight = 13
TabOrder = 0
end
object Edit1: TEdit
Left = 24
Top = 24
Width = 121
Height = 21
TabOrder = 1
Text = 'Edit1'
end
end
object GroupBox1: TGroupBox
Left = 344
Top = 24
Width = 185
Height = 201
Caption = 'GroupBox1'
TabOrder = 0
object ComboBox1: TComboBox
Left = 24
Top = 24
Width = 145
Height = 21
ItemHeight = 13
TabOrder = 0
Text = 'ComboBox1'
end
end
object ListBox3: TListBox
Left = 40
Top = 16
Width = 201
Height = 121
ItemHeight = 13
TabOrder = 2
end
endРедактирано от TRN на 14.06.01 00:51.
|
| |
|
|
|