Einzelnen Beitrag anzeigen

MrFish

Registriert seit: 16. Jul 2003
50 Beiträge
 
Delphi 7 Personal
 
#7

Re: Form lässt sich mit show nicht öffnen

  Alt 16. Nov 2004, 14:21
Das ist der komplette Code der fraglichen Form:
Code:
unit Unit8;

interface

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

type
  TVorlage = class(TForm)
    StringGrid1: TStringGrid;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure Button9Click(Sender: TObject);
    procedure StringGrid1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Vorlage: TVorlage;

implementation

{$R *.dfm}

procedure TVorlage.FormCreate(Sender: TObject);
var
  Default: TStringList;
  i     : Integer;
  j     : Integer;
  pos   : Integer;
begin

//----------------------------------------------------------------------------
//----------- Saltenköpf schreiben -------------------------------------------
//----------------------------------------------------------------------------

 StringGrid1.Cells [0,0] := 'von';
 StringGrid1.Cells [1,0] := 'bis';
 StringGrid1.Cells [2,0] := 'von';
 StringGrid1.Cells [3,0] := 'bis';
 StringGrid1.Cells [4,0] := 'von';
 StringGrid1.Cells [5,0] := 'bis';
 StringGrid1.Cells [6,0] := 'von';
 StringGrid1.Cells [7,0] := 'bis';
 StringGrid1.Cells [8,0] := 'von';
 StringGrid1.Cells [9,0] := 'bis';
 StringGrid1.Cells [10,0] := 'von';
 StringGrid1.Cells [11,0] := 'bis';

//----------------------------------------------------------------------------
//-------- Vorlagen laden ---------------------------------------------------
//---------------------------------------------------------------------------

Default := TStringList.create;
Default.LoadFromFile('c:/delphi/default.txt');

Pos := 0;
For j := 1 to 20 do
begin
  For i := 0 to 11 do
  begin
    StringGrid1.Cells[i,j] := default[pos];
    Pos := Pos + 1;
  end;
end;
Default.Destroy;
end;

procedure TVorlage.Button8Click(Sender: TObject);
var
  i : integer;
  j : integer;
  Default : TStringlist;
begin
  Default := TStringlist.Create;

//---------------------------------------------------------------------------
//-------- Vorlage abspeichern ----------------------------------------------
//---------------------------------------------------------------------------

  For j := 1 to 20 do
    begin
      for i := 0 to 11 do
      default.Add(StringGrid1.Cells[i,j]);
    end;
    Default.SaveToFile('C:/delphi/default.txt');
    Default.Destroy;
    Vorlage.Hide;
end;

procedure TVorlage.StringGrid1DrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
//--------------------------------------------------------------------------
//-------Tabelle nach Wochentagen unterteilen ------------------------------
//--------------------------------------------------------------------------

 begin
if Acol = 2 then
   begin
   StringGrid1.Canvas.Pen.Color:=clblack;
   StringGrid1.Canvas.Pen.Width:=1;
   StringGrid1.Canvas.moveto(Rect.Left,Rect.Top);
   StringGrid1.Canvas.Lineto(Rect.Left,Rect.Bottom);
   end;

if Acol = 4 then
   begin
   StringGrid1.Canvas.Pen.Color:=clblack;
   StringGrid1.Canvas.Pen.Width:=1;
   StringGrid1.Canvas.moveto(Rect.Left,Rect.Top);
   StringGrid1.Canvas.Lineto(Rect.Left,Rect.Bottom);
   end;

if Acol = 6 then
   begin
   StringGrid1.Canvas.Pen.Color:=clblack;
   StringGrid1.Canvas.Pen.Width:=1;
   StringGrid1.Canvas.moveto(Rect.Left,Rect.Top);
   StringGrid1.Canvas.Lineto(Rect.Left,Rect.Bottom);
   end;

if Acol = 8 then
   begin
   StringGrid1.Canvas.Pen.Color:=clblack;
   StringGrid1.Canvas.Pen.Width:=1;
   StringGrid1.Canvas.moveto(Rect.Left,Rect.Top);
   StringGrid1.Canvas.Lineto(Rect.Left,Rect.Bottom);
   end;

if Acol = 10 then
   begin
   StringGrid1.Canvas.Pen.Color:=clblack;
   StringGrid1.Canvas.Pen.Width:=1;
   StringGrid1.Canvas.moveto(Rect.Left,Rect.Top);
   StringGrid1.Canvas.Lineto(Rect.Left,Rect.Bottom);
   end;

if Acol = 12 then
   begin
   StringGrid1.Canvas.Pen.Color:=clblack;
   StringGrid1.Canvas.Pen.Width:=1;
   StringGrid1.Canvas.moveto(Rect.Left,Rect.Top);
   StringGrid1.Canvas.Lineto(Rect.Left,Rect.Bottom);
   end;

end;

end;

procedure TVorlage.Button9Click(Sender: TObject);
begin
  Vorlage.Hide;
end;

procedure TVorlage.StringGrid1Click(Sender: TObject);
begin

end;

end.
und hier der Aufruf:

procedure TWochenplan.VorlageClick(Sender: TObject);
begin
Vorlage.show;
end;
Es gibt zwei unbestreitbare Tatsachen: 1. Ich irre mich nie. 2. Die Welt ist eine Scheibe.
  Mit Zitat antworten Zitat