unit MainUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtnrs, Menus, ComCtrls, ToolWin, ImgList;

type
  TForm1 = class(TForm)
    OleContainer1: TOleContainer;
    MainMenu1: TMainMenu;
    ToolBar1: TToolBar;
    InsertButton: TToolButton;
    CloseButton: TToolButton;
    ImageList1: TImageList;
    PropertiesButton: TToolButton;
    SaveButton: TToolButton;
    OpenButton: TToolButton;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    InsertFromFileButton: TToolButton;
    OpenDialog1: TOpenDialog;
    procedure CloseButtonClick(Sender: TObject);
    procedure PropertiesButtonClick(Sender: TObject);
    procedure OpenButtonClick(Sender: TObject);
    procedure SaveButtonClick(Sender: TObject);
    procedure InsertButtonClick(Sender: TObject);
    procedure InsertFromFileButtonClick(Sender: TObject);
    procedure N2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses InsertFormUnit;

{$R *.dfm}

procedure TForm1.CloseButtonClick(Sender: TObject);
begin
 OleContainer1.Close;
end;

procedure TForm1.PropertiesButtonClick(Sender: TObject);
begin
 OleContainer1.ObjectPropertiesDialog;
end;

procedure TForm1.OpenButtonClick(Sender: TObject);
begin
 OleContainer1.LoadFromFile('ole.dat');
end;

procedure TForm1.SaveButtonClick(Sender: TObject);
begin
 OleContainer1.SaveToFile('ole.dat');
end;

procedure TForm1.InsertButtonClick(Sender: TObject);
begin
 InsertOLEForm.ShowModal;
 if InsertOLEForm.ModalResult=mrOK then
  OleContainer1.CreateObject(InsertOLEForm.ProgramsID.Strings[InsertOLEForm.OLEItemsListBox.ItemIndex], false);
end;

procedure TForm1.InsertFromFileButtonClick(Sender: TObject);
begin
 if OpenDialog1.Execute then
  OleContainer1.CreateObjectFromFile(OpenDialog1.FileName, false);
end;

procedure TForm1.N2Click(Sender: TObject);
begin
 Close;
end;

end.
