Accessing parent form's objects

Quote
David Eisenberg <d...@delbruck.pharm.sunysb.edu> wrote:
>eg.
>function DoIt(Sender:TObject);
>begin
>  CallFunctionInForm2(MainForm);
>end;
>function CallFunctionInForm2(Main: TObject);
>begin
>  Main.Panel1.Caption := 'Hi there!';
>end;

I'm surprised that this would compile since TObject does not have a
property called Panel1.

The question is, is where is CallFunctionInForm2 defined?  Is it in
its own unit?

Just for example, lets say you have two units, unit 1 and unit2.
Unit1 contains FORM1, and Unit2 contains FORM2.  In order for FORM2 to
access anything on FORM1, you use include Unit1 in the uses clause of
Unit2.

unit1
interface
type TForm1 = class(TForm)
.               ...
        end;
var
        MainForm: TForm1;
implementation
end.

unit2
interface
implementation
uses unit1;
begin
   MainForm.Panel1.Caption := 'This is from Unit2';
end;
end.

Brien King
bk...@primenet.com