<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">Le 13/09/2013 07:48, Richard Mace a
écrit :<br>
</div>
<blockquote
cite="mid:CAK+KT3-7tvUjck9iNokY+MihNDGg-xj4izJKZt=Z1uiNnaCDwQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_default"
style="font-family:arial,helvetica,sans-serif">OK, I now have
this code:</div>
<div class="gmail_default">
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">with
tvMain.Items.AddChildObject(tvMain.Selected,IntToStr(fUserList.Items[I].Id),Pointer(fUserList.Items[I].Id))
do</font></div>
<div style="font-family:arial,helvetica,sans-serif"><br>
</div>
</div>
<div class="gmail_extra">
<div class="gmail_default"
style="font-family:arial,helvetica,sans-serif">and this:</div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">procedure TfrmMain.tvMainChange(Sender:
TObject; Node: TTreeNode);</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">begin</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif"> if Assigned(Node.Data) then</font></div>
<div class="gmail_default">
<font face="arial, helvetica, sans-serif">
ShowMessage('Node ' + IntToStr(PtrInt(Node.Data)));</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">end;</font></div>
<div class="gmail_default">
<span style="font-family:arial,helvetica,sans-serif"></span><br>
</div>
<div class="gmail_default"
style="font-family:arial,helvetica,sans-serif">And I am now
getting an exception when my app run?</div>
<br>
<div class="gmail_default"
style="font-family:arial,helvetica,sans-serif">
Richard</div>
<br>
</div>
</div>
</blockquote>
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<br>
I added some nodes to the TTreeView like this:<br>
<br>
var<br>
SData: Integer=179;<br>
<br>
procedure TFrmMain.BtnTestTvClick(Sender: TObject);<br>
var<br>
wNode: TTreeNode = nil;<br>
s: String;<br>
begin<br>
Inc(SData);<br>
wNode := Ttv.Items.AddChildObject(nil, 'node new',
Pointer(SData));<br>
s := Format('node %s data:%d', [wNode.Text, PtrInt(wNode.Data)]);<br>
MessageDlg('Titre', s, mtInformation, [mbOK], 0, mbOK);<br>
end;<br>
<br>
The I added an event to Ttv.OnChange event like that:<br>
procedure TFrmMain.TtvChange(Sender: TObject; Node: TTreeNode);<br>
var<br>
wData: Integer;<br>
begin<br>
if Assigned(Node) then begin<br>
wData := PtrInt(Node.Data);<br>
MessageDlg('Titre',Format('data for "%s" %d', [Node.Text,
wData]), mtInformation, [mbOK], 0, mbOK);<br>
end;<br>
end;<br>
<br>
I get a new node on every BtnTestTvClick and a value starting from
180 on every OnChange event<br>
On both platforms.<br>
<br>
Antonio.<br>
<br>
</body>
</html>