unit CHILDWIN;

interface

uses Windows, Classes, Graphics, Forms, Controls, StdCtrls, ComCtrls,
  ExtCtrls, Movie, Grids, SysUtils;

type
  TMDIChild = class(TForm)
    RichEdit1: TRichEdit;
    Movie1: TMovie;    // Image1: TImage;
    StringGrid1: TStringGrid;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    procedure GetText (DateiName: String); virtual;
    procedure GetImage (DateiName: String); virtual;
    procedure GetTable (DateiName: String); virtual;
  end;

implementation

{$R *.dfm}

procedure TMDIChild.GetText (DateiName: String);
Begin
  // Bildfeld und Tabellenfeld verbergen, Textfeld zeigen
  Movie1.Hide;
  RichEdit1.Show;
  StringGrid1.Hide;
  RichEdit1.Lines.LoadFromFile (DateiName);
end;

procedure TMDIChild.GetImage (DateiName: String);
begin
  // Textfeld und Tabellenfeld verbergen, Bildfeld zeigen
  RichEdit1.Hide;
  StringGrid1.Hide;
  Movie1.Show;
  Movie1.Picture.LoadFromFile (DateiName);
end;

procedure TMDIChild.GetTable (DateiName: String);
var Anzahl, Zeilen, Spalten, i, j: Integer;
    Tabelle: TStringList;
begin
  // Textfeld und Bildfeld verbergen, Tabellenfeld zeigen
  RichEdit1.Hide;
  Movie1.Hide;
  StringGrid1.Show;
  // Stringliste erzeugen
  Tabelle := TStringList.Create;
  // Tabelleninhalt laden
  Tabelle.LoadFromFile (DateiName);
  Anzahl := Tabelle.Count;
  // Anzahl der Zeilen/Spalten ermitteln
  Zeilen  := StrToInt (Tabelle.Strings[Anzahl-2]);
  Spalten := StrToInt (Tabelle.Strings[Anzahl-1]);
  StringGrid1.RowCount := Zeilen;
  StringGrid1.ColCount := Spalten;
  // Zeilen-spaltenweise aus Tabelle in Stringgitter einlesen
  for i := 0 to Zeilen-1 do
    for j := 0 to Spalten-1 do
      StringGrid1.Cells[j,i] := Tabelle.Strings[i*Spalten+j];
end;

procedure TMDIChild.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TMDIChild.FormCreate(Sender: TObject);
begin
  RichEdit1.Align := alClient;
  RichEdit1.ScrollBars := ssBoth;
  Movie1.Align := alClient;
  Movie1.Center := true;
  StringGrid1.Align := alClient;
  StringGrid1.Options := StringGrid1.Options + [goEditing];
end;

end.
