On 11/05/2015 22:41, Anders Eriksson wrote:
How do I change properties for GUI-components from another unit?

e.g. hide a button or change a label text from a different unit.

Two example units that inter-communicate might be as follows:

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Forms, StdCtrls;

type

{ TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure FormShow(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

uses unit2;

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormShow(Sender: TObject);
begin
  Form2.Show;
end;

end.

================================================

unit Unit2;

{$mode objfpc}{$H+}

interface

uses
  Forms, StdCtrls;

type

  TForm2 = class(TForm)
    BChange: TButton;
    procedure BChangeClick(Sender: TObject);
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.lfm}

procedure TForm2.BChangeClick(Sender: TObject);
begin
  Form1.Button1.Hide;
  Form1.Label1.Caption:='Changed';
end;

end.

==================================================

The uses clauses are the critical feature.

Howard




---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to