Il 11/05/2015 23:41, Anders Eriksson ha scritto:
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.

If you have in unit1 a Form1 with a Button1 component, and Form1 is declared in the Interface section of unit1 (i.e. it's made "public"), in unit 2 you must have a clause "uses unit1" and then you can simply code
Form1.Button1.Hide
or
Form1.Button1.Caption := 'blah';

Only in case of ambiguity you must prepend also the unit name.
e.g. unit2 and unit3 both have a Panel1 component and they both have it declared in the Interface section. Then in unit1 you will have "uses unit2,unit3.
And to operate on them you will code:
unit2.Panel1.hide;
unit3.Panel1.show;

If there's no ambiguity, it's unnecessary.

Giuliano

--
Giuliano Colla

Project planning question: when it's 90% done, are we halfway or not yet?


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

Reply via email to