Thema: Delphi Second Form and Thread

Einzelnen Beitrag anzeigen

christian_r
(Gast)

n/a Beiträge
 
#7

Re: Second Form and Thread

  Alt 7. Mai 2008, 08:22
Zitat von mohfa:
Here is a Pseudo Code.
I think you should post the relevant code you really used.

Delphi-Quellcode:
On MainForm Creat Event
On MainForm Destroy
On TMainForm.Button1.Click
What is that? You should post pseudo code that could be used and doesn't have to be corrected.

Here is a code that works. It's tested! It's the code, you posted as a pseudo code. And it doesn't cause any compiler errors and it doesn't cause your problem. It works fine!

unit1
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Classes, Controls, StdCtrls, Forms, Dialogs;

type
  TForm1 = class( TForm )
    Button1 : TButton;
    Label1 : TLabel;
    Label2 : TLabel;
    procedure FormCreate
              ( Sender : TObject );
    procedure Button1Click
              ( Sender : TObject );
  end;

var
  Form1 : TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.FormCreate
          ( Sender : TObject );
begin
  if not Assigned( Form2 ) then
    Form2 := TForm2.Create( Nil );
end;

procedure TForm1.Button1Click
          ( Sender : TObject );
begin
  Form2.Label1.Caption := 'Caption Nr. 1';
  Form2.Label2.Caption := 'Caption Nr. 2';
  if Form2.ShowModal = mrOk then
    ShowMessage( 'Ok.' );
end;

end.
unit2
Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Classes, Controls, StdCtrls, Forms, Dialogs;

type
  TForm2 = class( TForm )
    Label1 : TLabel;
    Label2 : TLabel;
    Button1 : TButton;
    Button2 : TButton;
    procedure Button1Click
              ( Sender : TObject );
  end;

var
  Form2 : TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click
          ( Sender : TObject );
begin
  Self.ModalResult := mrOk;
end;

end.
And again ...
Check your code!
Stop to discuss!
Post your relevant code!
  Mit Zitat antworten Zitat