![]() |
|
#1
|
|||
|
|||
|
Hello,
I would like to add items to a listview/virtual treeview. The problem is the following: My application has Indy server 9 and I want to add a tlistitem/pvirtualnode every time the OnConnect gets fired. Unfortunately the OnConnect gets fired as a thread so if I get 1+ connections at the same time - it will add the items/nodes asychronized and the app causes to crash. I used CriticalSections but it seem not to work... (skips to add items/nodes sometimes) I heard I should use PostMessage or TThread but I never used it before. Does anybody have a solution? Here is my code: (Delphi7 / Indy9) procedure TForm1.IdTCPServer1Disconnect(AThread: TIdPeerThread); begin VirtualStringTree1.DeleteNode(PVirtualNode(Athread .Data)); // For Disconnection(s) end; procedure TForm1.IdTCPServer1Connect(AThread: TIdPeerThread); begin Athread.Data := TObject(VirtualStringTree1.AddChild(NIL)); // For Connection(s); end; |
![]() |
| Thread Tools | |
| Display Modes | |
|
|