Hallo allemaal,
Ik heb een gezamenlijke Unit2 welke door Unit1 en Unit3 worden gebruikt. Wanneer ik in Unit1(op Form1) Button1 aanklik dan wordt de tekst op het Panell1 vervangen door een andere tekst. Met Button2 (op Form1) wordt Test_Frm (Unit3) scherm geopend. In dit scherm wordt Button1 geactiveerd en wordt de zelfde procedure uit Unit2 doorlopen, echter zonder resultaat. Hoe los je dat op?
Frans
Code:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Unit2,Unit3, StdCtrls,
ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
Instellen(Form1);
end;
procedure TForm1.Button2Click(Sender: TObject);
Var Dlg : TTest_Frm;
begin
Dlg := TTest_Frm.Create(nil);
Dlg.ShowModal;
Dlg.Free;
end;
end.
// ==================================================
unit Unit2;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,Forms,ExtCtrls;
Procedure Instellen(AForm : TForm);
implementation
procedure Instellen(AForm : TForm);
var
I : Integer;
begin
for I := 0 to AForm.ComponentCount-1 do
if (AForm.Components[I] is TPanel) then
TPanel(AForm.Components[I]).Caption := 'aaaaaaaaa';
end;
end.
// ======================================================
unit Unit3;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
Unit2;
type
{ TTest_Frm }
TTest_Frm = class(TForm)
Button1: TButton;
Panel1: TPanel;
Panel2: TPanel;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Test_Frm: TTest_Frm;
implementation
{$R *.lfm}
{ TTest_Frm }
procedure TTest_Frm.Button1Click(Sender: TObject);
begin
Instellen(Test_Frm);
end;
end.
Bookmarks