Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
"TForm(AOwner)=TForm.Create(AOwner)"? Posted by earth_walker on 16 Jul 2003 at 3:06 PM
Hi!
in the code
constructor TOpenGL.Create(AOwner: TComponent);
var frm: Tform;
{some code}
frm:= TForm(AOwner);
{some code}

I just made a guess that "TForm(AOwner=TForm.Create(AOwner)". Is it true? If not, what does it mean?

Thank you!
Report
Re: "TForm(AOwner)=TForm.Create(AOwner)"? Posted by earth_walker on 16 Jul 2003 at 3:33 PM
There is another similar place in the code.
with TWinControl(Owner) do
begin
{some code}
end;

This call is in the definition of a method of a decendent(self defined) of TComponent.

Is it the same thing as "TForm(AOwner)"?

Thank you!

Report
Re: "TForm(AOwner)=TForm.Create(AOwner)"? Posted by zibadian on 16 Jul 2003 at 4:36 PM
: There is another similar place in the code.
:
: with TWinControl(Owner) do
: begin
: {some code}
: end;
: 

: This call is in the definition of a method of a decendent(self defined) of TComponent.
:
: Is it the same thing as "TForm(AOwner)"?
:
: Thank you!
:
:
Check out the Owner property and the with statement in the help files. In this case the owner needs to be type-cast as a TWinControl to access some of its methods and properties.
As for your previous question: The code is not the same as you put it, because the owner of an component is usually the form on which it is placed, while the owner of the forms itself is usually the application; and type-casting a TApplication object as a TForm will result in an error (Check the hierarchy of the TApplication and TForm objects).
Note: you cannot type-cast the left side of an assignment.
Report
Re: "TForm(AOwner)=TForm.Create(AOwner)"? Posted by earth_walker on 17 Jul 2003 at 4:35 AM
Thank you! I will check it.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.