Re: [Lazarus] TTreenode.data

2013-09-17 Thread Antonio Fortuny
Le 17/09/2013 07:16, Richard Mace a écrit : Thanks Antonio, that worked fine. Goodness knows what I was originally doing! Nothing less I did when I started to play with pointers. 8-) Happy to be usefull. Antonio. Richard -- ___ Lazarus mailing

Re: [Lazarus] TTreenode.data

2013-09-16 Thread Richard Mace
Thanks Antonio, that worked fine. Goodness knows what I was originally doing! Richard > > Details are missing about your implementation: Lzarus & FPC, OS, etc. > I've made a little test on Win32 and Linux_X64, Lazarus 1.0.12 > I added some nodes to the TTreeView like this: > > var > SData: In

Re: [Lazarus] TTreenode.data

2013-09-14 Thread Reinier Olislagers
Nice. Use FS a bit myself - nice to see Lazarus tooling for it appear. On 14/09/2013 08:45, Richard Mace wrote: > It is, and yes I am. :-) > > On 13 Sep 2013 16:01, "Reinier Olislagers" > wrote: > > On 13/09/2013 09:37, Antonio Fortuny wrote: > > Le

Re: [Lazarus] TTreenode.data

2013-09-13 Thread Richard Mace
It is, and yes I am. :-) On 13 Sep 2013 16:01, "Reinier Olislagers" wrote: > On 13/09/2013 09:37, Antonio Fortuny wrote: > > Le 13/09/2013 07:48, Richard Mace a écrit : > >> OK, I now have this code: > > Details are missing about your implementation: Lzarus & FPC, OS, etc. > > Guessing Windows x

Re: [Lazarus] TTreenode.data

2013-09-13 Thread Reinier Olislagers
On 13/09/2013 09:37, Antonio Fortuny wrote: > Le 13/09/2013 07:48, Richard Mace a écrit : >> OK, I now have this code: > Details are missing about your implementation: Lzarus & FPC, OS, etc. Guessing Windows x86 - not writing a FreeSwitch control application, by any chance [1] ;) http://thread.gm

Re: [Lazarus] TTreenode.data

2013-09-13 Thread Antonio Fortuny
Le 13/09/2013 07:48, Richard Mace a écrit : OK, I now have this code: with tvMain.Items.AddChildObject(tvMain.Selected,IntToStr(fUserList.Items[I].Id),Pointer(fUserList.Items[I].Id)) do and this: procedure TfrmMain.tvMainChange(Sender: TObject; Node: TTreeNode); begin if Assigned(Node.Data

Re: [Lazarus] TTreenode.data

2013-09-12 Thread Juha Manninen
On Fri, Sep 13, 2013 at 8:48 AM, Richard Mace wrote: > And I am now getting an exception when my app run? Use debugger to see what goes wrong. Juha -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/ma

Re: [Lazarus] TTreenode.data

2013-09-12 Thread Richard Mace
OK, I now have this code: with tvMain.Items.AddChildObject(tvMain.Selected,IntToStr(fUserList.Items[I].Id),Pointer(fUserList.Items[I].Id)) do and this: procedure TfrmMain.tvMainChange(Sender: TObject; Node: TTreeNode); begin if Assigned(Node.Data) then ShowMessage('Node ' + IntToStr(PtrInt(N

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Mattias Gaertner
On Thu, 12 Sep 2013 06:39:55 +0100 Richard Mace wrote: > [...] > procedure TfrmMain.tvMainSelectionChanged(Sender: TObject); > begin Sender is the tvMain. > if Assigned(TTreeNode(Sender).Data) then > ShowMessage('Node ' + IntToStr(TUser(TTreeNode(Sender).Data).Id)); > end; > > I'm obviou

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Richard Mace
On 11 September 2013 10:19, Graeme Geldenhuys wrote: > On 2013-09-11 06:51, Richard Mace wrote: > > Can anyone give me an example of adding and retrieving an integer value > to > > a TTreenode via it's data property please? > > The Data property holds a pointer value, so don't assign an Integer >

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Flávio Etrusco
On Wed, Sep 11, 2013 at 6:19 AM, Graeme Geldenhuys wrote: > On 2013-09-11 06:51, Richard Mace wrote: >> Can anyone give me an example of adding and retrieving an integer value to >> a TTreenode via it's data property please? > > The Data property holds a pointer value, so don't assign an Integer >

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Hans-Peter Diettrich
Howard Page-Clark schrieb: On 11/09/2013 18:03, Flávio Etrusco wrote: On Wed, Sep 11, 2013 at 5:41 AM, Howard Page-Clark procedure TfrmMain.tvMainChange(Sender: TObject; Node: TTreeNode); begin if Assigned(Node) then ShowMessage('Node ' + IntToStr(PtrInt(Node.Data))); I guess you

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Flávio Etrusco
On Wed, Sep 11, 2013 at 5:41 AM, Howard Page-Clark wrote: > > > Also unless you want the treeview to behave as if it were fully initialised > with Data integer values of zero, you would need to add: > > > > procedure TfrmMain.tvMainChange(Sender: TObject; Node: TTreeNode); > begin > if Assigned(

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Howard Page-Clark
On 11/09/2013 18:03, Flávio Etrusco wrote: On Wed, Sep 11, 2013 at 5:41 AM, Howard Page-Clark wrote: Also unless you want the treeview to behave as if it were fully initialised with Data integer values of zero, you would need to add: procedure TfrmMain.tvMainChange(Sender: TObject; Node: T

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Lukasz Sokol
On 11/09/13 14:02, Juha Manninen wrote: > On Wed, Sep 11, 2013 at 3:24 PM, Richard Mace wrote: >> Can't it be type casted because both a pointer and integer are 4 bytes? > > They are both 4 bytes only in 32-bit computers. > > Juha > And if your program is compiled to 32bit executable and ran

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Hans-Peter Diettrich
Antonio Fortuny schrieb: Le 11/09/2013 07:51, Richard Mace a écrit : Hi, Can anyone give me an example of adding and retrieving an integer value to a TTreenode via it's data property please? I've tried the below, but it doesn't seem to work. Set: with tvMain.Items.AddChildObject(tvMain.Sel

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Hans-Peter Diettrich
Richard Mace schrieb: Thanks for the reply. Can't it be type casted because both a pointer and integer are 4 bytes? Dunno about Lazarus, but casts work in Delphi. Hint: pointers may be longer than integers, but never shorter. So you won't loose information when e.g. storing an 32 bit integer

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Graeme Geldenhuys
On 2013-09-11 14:02, Juha Manninen wrote: > > They are both 4 bytes only in 32-bit computers. +1 Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ -- ___ Lazarus mailing list

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Juha Manninen
On Wed, Sep 11, 2013 at 3:24 PM, Richard Mace wrote: > Can't it be type casted because both a pointer and integer are 4 bytes? They are both 4 bytes only in 32-bit computers. Juha -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http:

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Richard Mace
Thanks for the reply. Can't it be type casted because both a pointer and integer are 4 bytes? On 11 Sep 2013 10:46, "Graeme Geldenhuys" wrote: > On 2013-09-11 06:51, Richard Mace wrote: > > Can anyone give me an example of adding and retrieving an integer value > to > > a TTreenode via it's data

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Graeme Geldenhuys
On 2013-09-11 06:51, Richard Mace wrote: > Can anyone give me an example of adding and retrieving an integer value to > a TTreenode via it's data property please? The Data property holds a pointer value, so don't assign an Integer directly. Rather define a Record structure (or a Class) that holds

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Howard Page-Clark
On 11/09/2013 09:24, Antonio Fortuny wrote: Le 11/09/2013 07:51, Richard Mace a écrit : procedure TfrmMain.tvMainChange(Sender: TObject; Node: TTreeNode); begin ShowMessage('Node ' + IntToStr(Integer(Node.Data))); change to: ShowMessage('Node ' + IntToStr(*PtrInt***(Node.Data))); Also unles

Re: [Lazarus] TTreenode.data

2013-09-11 Thread Antonio Fortuny
Le 11/09/2013 07:51, Richard Mace a écrit : Hi, Can anyone give me an example of adding and retrieving an integer value to a TTreenode via it's data property please? I've tried the below, but it doesn't seem to work. Set: with tvMain.Items.AddChildObject(tvMain.Selected,'string',TObject(fUs