A better way...
type
TMyForm = class(TForm)
public
Test: integer;
end;
procedure Foo(F: TForm)
begin
if (F is TMyForm) then
(F as TMyForm).Test := 0;
end;
Adding an else stmt Assert(False) can do a future programmer a big favor too.
I suggest you refrain from doing casts in format
TMyClass(aBaseClass).
When someone breaks this it might take time to find out why since Delphi has
never been very good at taking you to such errors reliably.
HTH
Tom
----- Original Message ----
From: Wilfried Mestdagh <[EMAIL PROTECTED]>
To: Borland's Delphi Discussion List <[email protected]>
Sent: Thursday, January 25, 2007 1:26:36 AM
Subject: Re[2]: Scope and Message Passing
Hello Alan,
> as long as I only need to access TForm
> properties. The problem--obvious to all of you--is that any GUI form
> we use inherits from TForm and has additional properties, (component)
> fields, etc. None of these would be available when I pass a reference
> to TForm.
You can do this with a proper type cast. Just tell the compiler that
this particular object is something else:
type
TMyForm = class(TForm)
public
Test: integer;
end;
procedure Foo(F: TForm)
begin
TMyForm(F).Test := 0;
end;
---
Rgds, Wilfried
http://www.mestdagh.biz
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi