![]() |
Re: Variablen zwischen 2 Formularen übermitteln
Liste der Anhänge anzeigen (Anzahl: 1)
OK.. maybe not optimal but working.
Eine Loesungsmoeglichkeit ueber Events. Deine "Main-FormA"
Delphi-Quellcode:
Deine "FormB"
unit Unit_A;
interface uses Unit_B, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm_A = class(TForm) editA: TEdit; procedure editAChange(Sender: TObject); private { Private-Deklarationen } Form_B: TForm_B; Procedure GotNotifyFromB(text:String); public { Public-Deklarationen } constructor create(AOwner:TComponent); override; destructor destroy; override; end; var Form_A: TForm_A; implementation {$R *.dfm} constructor TForm_A.create(AOwner:TComponent); begin inherited; Form_B := TForm_B.Create(Self); Form_B.DoNotifyA := GotNotifyFromB; Form_B.Constraints := Self.Constraints; Form_B.Top := Self.Top; Form_B.Left := Self.Left+Self.Width; Form_B.Show; end; destructor TForm_A.destroy; begin if Assigned(Form_B) then Form_B.Free; inherited; end; Procedure TForm_A.GotNotifyFromB(text:String); begin editA.Text := text; end; procedure TForm_A.editAChange(Sender: TObject); begin if Assigned(Form_B) then Form_B.editB.Text := editA.Text; end; end.
Delphi-Quellcode:
unit Unit_B;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TEditNotify = Procedure(text:String) of object; TForm_B = class(TForm) editB: TEdit; procedure editBChange(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); private { Private-Deklarationen } FDoNotifyA : TEditNotify; public { Public-Deklarationen } property DoNotifyA:TEditNotify read FDoNotifyA write FDoNotifyA; end; implementation {$R *.dfm} procedure TForm_B.editBChange(Sender: TObject); begin if Assigned(FDoNotifyA) then FDoNotifyA(editB.Text); end; procedure TForm_B.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin CanClose := False; end; end. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:48 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz