Einzelnen Beitrag anzeigen

Benutzerbild von ManuMF
ManuMF

Registriert seit: 11. Jul 2005
1.016 Beiträge
 
Delphi 6 Personal
 
#7

Re: Mainform erst anzeigen nachdem andere Form geschlossen w

  Alt 15. Aug 2005, 16:39
Ich hätte es so gelöst:

Delphi-Quellcode:
// HauptForm

unit HauptUnit;

interface

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

type
  THauptForm = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  HauptForm: THauptForm;

implementation

{$R *.dfm}

procedure THauptForm.FormCreate(Sender: TObject);
begin
  Application.ShowMainForm := false;
  AnfangsForm.Show;
end;

end.




// Formular, das zuerst angezeigt werden soll:

unit AnfangsUnit;

interface

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

type
  TAnfangsForm = class(TForm)
    WeiterButton: TButton;
    procedure WeiterButtonClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  AnfangsForm: TAnfangsForm;
  UserEingabe : Boolean;

implementation

{$R *.dfm}

uses HauptUnit;



procedure TAnfangsForm.WeiterButtonClick(Sender: TObject);
begin
  UserEingabe := true;
  AnfangsForm.Close;
  HauptForm.Show;
end;

proceudre TAnfangsForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if not (UserEingabe) then
    Aplication.Terminate;
end;

end.
Wichtig ist die Erwähnung in uses, bei Unit2 aber hinter implementation.
Das OnClose-Ereignis beendet die Anwendung, wenn der User nichts getan hat. Sonst bleibt das Programm ohne sichtbares Fenster trotzdem da.

Gruß,
ManuMF
  Mit Zitat antworten Zitat