unit uCheckBoxSelection;

interface

uses
  System.Classes;

type
  TCheckBoxSelectionThread = class(TThread)
  private
    { Private declarations }
  protected

    Procedure ListParentAndAllChildren(NodeID:Integer);

    procedure Execute; override;
  end;

implementation

{ 
  Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);  

  and UpdateCaption could look like,

    procedure TCheckBoxSelectionThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; 
    
    or 
    
    Synchronize( 
      procedure 
      begin
        Form1.Caption := 'Updated in thread via an anonymous method' 
      end
      )
    );
    
  where an anonymous method is passed.
  
  Similarly, the developer can call the Queue method with similar parameters as 
  above, instead passing another TThread class as the first parameter, putting
  the calling thread in a queue with the other thread.
    
}

{ TCheckBoxSelectionThread }

procedure TCheckBoxSelectionThread.Execute;
begin



  { Place thread code here }
end;

procedure TCheckBoxSelectionThread.ListParentAndAllChildren(NodeID: Integer);
var qSelectAllChildren:TFDQuery;

begin

   qSelectAllChildren:=TFDQuery.Create(Self);
   qSelectAllChildren.Connection:=FDConnection;

//   FIDList.Add(NodeID.ToString);
   GlobalIDList.Add(NodeID.ToString); // Вспомогательно, дублируем

   with qSelectAllChildren do
   begin

    SQL.Text:='SELECT * FROM treeview_db.tree where IdParent='+NodeID.ToString;

    Open();

    while not eof do
     begin

     ListParentAndAllChildren(FieldByName('id').AsInteger);

     Next;
     end;

    Close();
   end;

   qSelectAllChildren.Free;

end;
;

end.
