[Lazarus] object casting to pointer

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Nov 24 00:01:12 CET 2010


On Tue, 23 Nov 2010 15:41:20 -0600
Marco Aurelio Ramirez Carrillo <stardev.mramirez at gmail.com> 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;

This works here.
Please provide a more complete example.


> // typecasting lowercase
> MyTreeNode.Data := pointer(MyObject);
> // typecasting capital
> MyTreeNode.Data := Pointer(MyObject);
> // typecasting with address operator

Pascal types are case insensitive.


> MyTreeNode.Data := pointer(@MyObject);

Simply wrong.

Mattias




More information about the Lazarus mailing list