[Lazarus] TTreeView events OnCreateNodeClass and OnAddition

Mattias Gaertner nc-gaertnma at netcologne.de
Sat May 1 16:46:02 CEST 2010


On Sat, 1 May 2010 17:42:09 +0300
Juha Manninen <juha.manninen at phnet.fi> wrote:

> Andrew Haines wrote:
> > > Delphi compatibility issue again. TTreeView is missing events:
> > >   TTreeView.OnCreateNodeClass and 
> > 
> > LCL has TTreeView.OnCustomCreateItem which may do what you want for this
> 
> Now this may be a stupid question but what is the easiest way to use node 
> class derived from TTreeNode, instead of TTreeNode itself?
> 
> In the program I try to port there is:
> 
>   TViewNode = class(TTreeNode)
>   ...
> 
> Then OnCreateNodeClass handler is used only to indicate the node class type:
> 
>   procedure TTreeViewIntegrator.tvModelCreateNodeClass(
>     Sender:   TCustomTreeView; var NodeClass: TTreeNodeClass);
>   begin
>     NodeClass := TViewNode;
>   end;
> 
> 
> In OnCustomCreateItem handler I would need to actually create the node and 
> take care of owner and parent or siblings or whatever.

The easiest way would be a simple property NodeClass: TTreeNodeClass.

For Delphi compatibility I added OnCreateNodeClass.

Mattias




More information about the Lazarus mailing list