Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#15

Re: Anzeige der Nebenform vor der Hauptform

  Alt 29. Jan 2006, 15:49
Hast du auch den Code in Form2 angepasst?

Delphi-Quellcode:
procedure TForm2.Button1Click(Sender: TObject);
begin
  if Edit1.Text = Password
    then ModalResult := mrOK
    else ShowMessage(Password);
end;

procedure TForm2.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  if Edit1.Text = Password
    then ModalResult := mrOK
    else ModalResult := mrCancel;
end;
Und im Projekt-Quelltext (DPR) steht jetzt:

Delphi-Quellcode:
program Demo;

uses
  Forms,
  Controls,
  Unit1 in 'Unit1.pas{Form1},
  Unit2 in 'Unit2.pas{Form2};

{$R *.res}

var
  mr: TModalResult;

begin
  with TForm2.Create(nil) do
  begin
    mr := ShowModal;
    Free;
  end;
  if mr = mrCancel then
    Exit;
    
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
marabu
  Mit Zitat antworten Zitat