Einzelnen Beitrag anzeigen

DennisHB

Registriert seit: 25. Aug 2003
Ort: Bremen
58 Beiträge
 
Delphi 6 Personal
 
#9

Re: 2 Units und 2 Formulare...

  Alt 7. Sep 2006, 20:28
Delphi-Quellcode:
unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
     If Form1.Visible then begin
          Form1.Hide;
          Form2.Show;
     end else begin
          Form2.Hide;
          Form1.Show;
     end;
end;

end.
Delphi-Quellcode:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
     Form1.Button1Click(Sender);
end;

end.
Wobei diese Lösung nicht sehr schön ist
  Mit Zitat antworten Zitat