Thank you very much for your answer.

I will try it out tomorrow.
I have struggled with this for weeks.


/anders

Howard Page-Clark skrev den 2015-05-12 00:43:
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
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.5941 / Virus Database: 4342/9751 - Release Date: 05/11/15





-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.5941 / Virus Database: 4342/9751 - Release Date: 05/11/15


--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to