[Lazarus] object casting to pointer

Leonardo M. Ramé l.rame at griensu.com
Tue Nov 23 23:53:44 CET 2010


On 2010-11-23 15:41:20 -0600, Marco Aurelio Ramirez Carrillo wrote:
> Hi.
> I'm working witha TTreeview, and trying to assign a object to a
> TTreeNode.data property:
> 
> <code>
> MyTreeNode := myTreeview.add(nil, "MyTreeNode");
> 
> // any "TObject" descendant class
> MyObject = MyClass.Create();
> 
> // all of these, generate a syntax/semantic error:
> 
> // no typecasting
> MyTreeNode.Data := MyObject;
> // typecasting lowercase
> MyTreeNode.Data := pointer(MyObject);
> // typecasting capital
> MyTreeNode.Data := Pointer(MyObject);
> // typecasting with address operator
> MyTreeNode.Data := pointer(@MyObject);
> </code>
> 
> But none of them seems to work.
> I already search in the wiki. Any idea, what is missing ?
> 
> Thanks.
> 
> stardev tod maramirezc ta gmail tod com
> 

I did a quick test using this:

TreeView1.Items[0].Data := @MyObject;

And it compiled without problem.

-- 
Leonardo M. Ramé
http://leonardorame.blogspot.com




More information about the Lazarus mailing list