Показать сообщение отдельно
  #2  
Старый 06.01.2011, 11:27
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Shape1: TShape;
    Shape2: TShape;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  resourcestream: TFileStream;
begin
  resourcestream:=TFileStream.Create('c:\Downloads\Shape1.dfm', fmCreate);
  try
    resourcestream.WriteComponentRes('Shape1', Shape1);
    resourcestream.WriteComponentRes('Shape2', Shape2);
  finally
    resourcestream.Free;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  aform: TForm;
  resourcestream: TFileStream;
  component: TShape;
begin
  aform:=TForm.Create(Application);
  aform.Width:=Width;
  aform.Height:=Height;
  aform.Show;
  resourcestream:=TFileStream.Create('c:\Downloads\Shape1.dfm', fmOpenRead);
  try
    component:=TShape.Create(aform);
    component.Parent:=aform;
    resourcestream.ReadComponentRes(component);
    component:=TShape.Create(aform);
    component.Parent:=aform;
    resourcestream.ReadComponentRes(component);
  finally
    resourcestream.Free;
  end;
end;

end.
http://data.cod.ru/83095
__________________
Пишу программы за еду.
__________________
Ответить с цитированием