unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Menus, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure Image1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function StringToComponent(Value: string;Instance: TComponent): TComponent;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
L:TStringList;
begin
RegisterClass(TForm);
RegisterClass(TButton);
RegisterClass(TPanel);
RegisterClass(TCheckBox);
RegisterClass(TImage);
RegisterClass(TPopupMenu);
RegisterClass(TMenuItem);
//...
RegisterClass(TListView);
if OpenDialog1.Execute then
begin
L:=TStringList.Create;
L.LoadFromFile(OpenDialog1.FileName);
(StringToComponent(L.Text,Nil) as TForm).Show;
L.Free;
end;
end;
function StringToComponent(Value: string;Instance: TComponent): TComponent;
var
StrStream:TStringStream;
BinStream: TMemoryStream;
begin
StrStream := TStringStream.Create(Value);
try
BinStream := TMemoryStream.Create;
try
ObjectTextToBinary(StrStream, BinStream);
BinStream.Seek(0, soFromBeginning);
Result := BinStream.ReadComponent(Instance);
finally
BinStream.Free;
end;
finally
StrStream.Free;
end;
end;
procedure TForm1.Image1Click(Sender: TObject);
begin
end;
end.
{Form1.DFM}
object Form1: TForm
Left = 480
Top = 108
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Image1: TImage
Left = 80
Top = 136
Width = 105
Height = 105
Picture.Data = {
07544269746D617076010000424D760100000000000076000000280000002000
000010000000010004000000000000010000120B0000120B0000100000000000
0000000000000000800000800000008080008000000080008000808000007F7F
7F00BFBFBF000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF
FF00333333333333333333333333333333333333333333333333333FF3333333
3FF333003333333300333377FF33333377FF300003333330000337777FFFFFF7
777F000000000000000077777777777777770F88FFFF8FFF88F07F333F333333
33370FFF9FFF8FFFFF707F337FF333FFFFF70FF999FF800000037F3777333777
77730FFF9FFF088880337F3373337F3337330FFFFFFF088803337FFFFFFF7FFF
73337000000000003333777777777777F3333333333939993933333333333777
3333333333333393333333333333337333333333333393339333333333333333
3333333333333393333333333333333333333333333333333333333333333333
3333}
end
object Button1: TButton
Left = 16
Top = 24
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
end
object Panel1: TPanel
Left = 72
Top = 208
Width = 185
Height = 41
Caption = 'Panel1'
TabOrder = 1
end
object CheckBox1: TCheckBox
Left = 112
Top = 288
Width = 97
Height = 17
Caption = 'CheckBox1'
TabOrder = 2
end
object ListView1: TListView
Left = 296
Top = 184
Width = 250
Height = 150
Columns = <>
TabOrder = 3
end
end