home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / nastroje / d5 / MFTP.ZIP / src / FtpTreeView.pas < prev    next >
Pascal/Delphi Source File  |  2001-03-05  |  18KB  |  772 lines

  1. unit FtpTreeView;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  7.   ComCtrls, ImgList, ShellApi, Ftp, FtpCache, FtpData, FtpMisc;
  8.  
  9. {$i mftp.inc}
  10.  
  11. type
  12.    TMFtpTreeView = class;
  13.  
  14.    TMFtpSiteInfo = class(TPersistent)
  15.    private
  16.       FTreeView:                 TMFtpTreeView;
  17.       FCount:                    Integer;
  18.  
  19.       FRootInfoT:                TStrings;
  20.       FRootInfoP:                TList;
  21.    public
  22.       constructor Create(AOwner: TMFtpTreeView);
  23.       destructor Destroy; override;
  24.  
  25.       property Count: Integer read FCount;
  26.       property RootInfoP: TList read FRootInfoP;
  27.       property RootInfoT: TStrings read FRootInfoT;
  28.  
  29.       procedure Add(TopURL: String; TN: TTreeNode);
  30.       procedure Clear;
  31.       procedure Delete(TN: TTreeNode); overload;
  32.       procedure Delete(N: Integer); overload;
  33.    end;
  34.  
  35.    TMFtpTreeView = class(TCustomTreeView)
  36.    private
  37.       FFtp:                      TMFtp;
  38.       FSiteInfo:                 TMFtpSiteInfo;
  39.  
  40.       FAccept:                   Boolean;
  41.       FPreload:                  Boolean;
  42.       FWebStyle:                 Boolean;
  43.  
  44.       FFileDropped:              TStrings;
  45.  
  46.       SysImageS:                 TImageList;
  47.       MyImage:                   TImageList;
  48.  
  49.       HOnDirectoryChanged:       Integer;
  50.       HOnFtpInfo:                Integer;
  51.       HOnListingDone:            Integer;
  52.  
  53.       FFileDroppedE:             TNotifyEvent;
  54.  
  55.       FRoot, FCurrentDir:        TTreeNode;
  56.  
  57.       Flag:                      Boolean;
  58.  
  59.       function IsTreeNodeExists(T: TTreeNode; C: String): TTreeNode;
  60.       procedure PreloadDir(S: String; Level: Integer);
  61.       procedure UpdateView(D: TMFtpFileInfoList);
  62.  
  63.       procedure SetAccept(A: Boolean);
  64.       procedure SetClient(NewFtp: TMFtp);
  65.       procedure SetWebStyle(W: Boolean);
  66.  
  67.       procedure NewOnClick(Sender: TObject);
  68.       procedure NewOnCollapsing(Sender: TObject; Node: TTreeNode; var AllowCollapse: Boolean);
  69.       procedure NewOnEditing(Sender: TObject; Item: TTreeNode; var AllowEdit: Boolean);
  70.       procedure NewOnExpanding(Sender: TObject; Node: TTreeNode;
  71.                                var AllowExpansion: Boolean);
  72.  
  73.       procedure NewOnDirectoryChanged(Sender: TObject);
  74.       procedure NewOnFtpInfo(Sender: TObject; info: FtpInfo; addinfo: String);
  75.       procedure NewOnListingDone(Sender: TObject);
  76.    protected
  77.       procedure CreateWnd; override;
  78.       procedure WMDropFiles(var msg : TMessage); message WM_DROPFILES;
  79.    public
  80.       constructor Create(AOwner: TComponent); override;
  81.       destructor Destroy; override;
  82.  
  83.       property FileDropped: TStrings read FFileDropped;
  84.       property Root: TTreeNode read FRoot write FRoot;
  85.       property Sites: TMFtpSiteInfo read FSiteInfo;
  86.  
  87.       property Items;
  88.  
  89.       function GetTreeNodeName(N: TTreeNode): String;
  90.       procedure Locate(S: String);
  91.  
  92.       procedure CollapseAll;
  93.       procedure ExpandAll;
  94.    published
  95.       property Accept: Boolean read FAccept write SetAccept;
  96.       property Client: TMFtp read FFtp write SetClient;      
  97.       property Preload: Boolean read FPreload write FPreload;
  98.       property WebStyle: Boolean read FWebStyle write SetWebStyle;
  99.  
  100.       property Align;
  101.       property BorderStyle;
  102.       property Color;
  103.       property Ctl3D;
  104.       property DragCursor;
  105.       property DragMode;
  106.       property Enabled;
  107.       property Font;
  108.       property HideSelection;
  109.       property Indent;
  110.       property ParentColor default False;
  111.       property ParentCtl3D;
  112.       property ParentFont;
  113.       property ParentShowHint;
  114.       property PopupMenu;
  115.       property ReadOnly;
  116.       property RightClickSelect;
  117.       property ShowButtons;
  118.       property ShowHint;
  119.       property ShowLines;
  120.       property ShowRoot;
  121.       property SortType;
  122.       property TabOrder;
  123.       property TabStop default True;
  124.       property Visible;
  125.  
  126.       property Anchors;
  127.       property AutoExpand;
  128.       property BiDiMode;
  129.       property BorderWidth;
  130.       property ChangeDelay;
  131.       property Constraints;
  132.       property DragKind;
  133.       property ParentBiDiMode;
  134.       property RowSelect;
  135.  
  136.       {$ifdef EXPORT_IMAGES}
  137.       property Images;
  138.       property StateImages;
  139.       {$endif}
  140.  
  141.       property OnFileDropped: TNotifyEvent read FFileDroppedE write FFileDroppedE;
  142.  
  143.       property OnChange;
  144.       property OnChanging;
  145.       property OnClick;
  146.       property OnCollapsed;
  147.       property OnCollapsing;
  148.       property OnCompare;
  149.       property OnDblClick;
  150.       property OnDeletion;
  151.       property OnDragDrop;
  152.       property OnDragOver;
  153.       property OnEdited;
  154.       property OnEditing;
  155.       property OnEndDrag;
  156.       property OnEnter;
  157.       property OnExit;
  158.       property OnExpanded;
  159.       property OnExpanding;
  160.       property OnGetImageIndex;
  161.       property OnGetSelectedIndex;
  162.       property OnKeyDown;
  163.       property OnKeyPress;
  164.       property OnKeyUp;
  165.       property OnMouseDown;
  166.       property OnMouseMove;
  167.       property OnMouseUp;
  168.       property OnStartDrag;
  169.  
  170.       property OnCustomDraw;
  171.       property OnCustomDrawItem;
  172.       property OnEndDock;
  173.       property OnStartDock;
  174.  
  175.       {$ifdef DELPHI5}
  176.       property OnAdvancedCustomDraw;
  177.       property OnAdvancedCustomDrawItem;
  178.       property OnContextPopup;
  179.       {$endif}
  180.    end;
  181.  
  182. implementation
  183.  
  184. constructor TMFtpTreeView.Create;
  185. var ShInfo:  TSHFileInfo;
  186.     TmpIcon: TIcon;
  187.     TmpBmp:  TBitmap;
  188. begin
  189.    inherited Create(AOwner);
  190.  
  191.    FFileDropped := TStringList.Create;
  192.    FSiteInfo := TMFtpSiteInfo.Create(Self);
  193.  
  194.    SysImageS := TImageList.Create(Self);
  195.    with SysImageS do
  196.    begin
  197.       ShareImages := True;
  198.       Handle := SHGetFileInfo('', 0, ShInfo, SizeOf(TSHFileInfo),
  199.                 SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
  200.    end;
  201.  
  202.    MyImage := TImageList.Create(Self);
  203.    Images := MyImage;
  204.  
  205.    TmpIcon := TIcon.Create;
  206.    with TmpIcon do
  207.    try
  208.       SHGetFileInfo(PChar(GetWindowsDirectory), 0, ShInfo, SizeOf(ShInfo),
  209.                     SHGFI_SYSICONINDEX or SHGFI_SMALLICON or SHGFI_OPENICON);
  210.       SysImageS.GetIcon(ShInfo.iIcon, TmpIcon);
  211.       MyImage.AddIcon(TmpIcon);
  212.    finally
  213.       Free;
  214.    end;
  215.  
  216.    TmpIcon := TIcon.Create;
  217.    with TmpIcon do
  218.    try
  219.       SHGetFileInfo(PChar(GetWindowsDirectory), 0, ShInfo, SizeOf(ShInfo),
  220.                     SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
  221.       SysImageS.GetIcon(ShInfo.iIcon, TmpIcon);
  222.       MyImage.AddIcon(TmpIcon);
  223.    finally
  224.       Free;
  225.    end;
  226.  
  227.    TmpBmp := TBitmap.Create;
  228.    with TmpBmp do
  229.    try
  230.       LoadFromResourceName(HInstance, 'REMOTE_FOLDER');
  231.       MyImage.Add(TmpBmp, nil);
  232.    finally
  233.       Free;
  234.    end;
  235.  
  236.    OnEditing := NewOnEditing;
  237.  
  238.    SortType := stText;
  239.    {$ifdef VER120}
  240.    ChangeDelay := 50;
  241.    {$endif}
  242.  
  243.    FPreload := True;
  244. end;
  245.  
  246. procedure TMFtpTreeView.CreateWnd;
  247. begin
  248.    inherited CreateWnd;
  249.  
  250.    SetAccept(True);
  251.    SetWebStyle(True);
  252.  
  253.    ShowRoot := False;
  254. end;
  255.  
  256. destructor TMFtpTreeView.Destroy;
  257. begin
  258.    Images := nil;
  259.    FreeAndNil(MyImage);
  260.  
  261.    FreeAndNil(FFileDropped);
  262.    FSiteInfo.Destroy;
  263.  
  264.    inherited Destroy;
  265. end;
  266.  
  267. procedure TMFtpTreeView.WMDropFiles;
  268. var DHandle: HDrop;
  269.     i, nb: Integer;
  270.     fn : array[0..254] of char;
  271. begin
  272.    FFileDropped.Clear;
  273.  
  274.    DHandle := Msg.WParam;
  275.    nb:=DragQueryFile(DHandle, $FFFFFFFF, fn, sizeof(fn));
  276.    for i := 0 to nb - 1 do
  277.    begin
  278.       DragQueryFile(DHandle, i, fn, sizeof(fn));
  279.       FFileDropped.Add(fn);
  280.    end;
  281.    DragFinish(DHandle);
  282.  
  283.    if Assigned(FFileDroppedE) then FFileDroppedE(Self);
  284. end;
  285.  
  286. procedure TMFtpTreeView.SetAccept;
  287. begin
  288.    FAccept := A;
  289.  
  290.    DragAcceptFiles(Self.Handle, A);
  291. end;
  292.  
  293. procedure TMFtpTreeView.SetClient;
  294. begin
  295.    if FFtp = NewFtp then Exit;
  296.  
  297.    if Assigned(FFtp) then
  298.    begin
  299.       with FFtp do
  300.       begin
  301.          UnRegisterInfoEvent(HOnFtpInfo);
  302.          UnRegisterNotifyEvent(1, HOnDirectoryChanged);
  303.          UnRegisterNotifyEvent(10, HOnListingDone);
  304.        end;
  305.    end;
  306.  
  307.    FFtp := NewFtp;
  308.  
  309.    if not Assigned(FFtp) then
  310.    begin
  311.       Items.Clear;
  312.       Exit;
  313.    end;
  314.  
  315.    with FFtp do
  316.    begin
  317.       HOnFtpInfo := RegisterInfoEvent(NewOnFtpInfo);
  318.       HOnDirectoryChanged := RegisterNotifyEvent(1, NewOnDirectoryChanged);
  319.       HOnListingDone := RegisterNotifyEvent(10, NewOnListingDone);
  320.    end;
  321.  
  322.    {refresh}
  323.    if FFtp.Directories.Count + FFtp.Files.Count >0 then NewOnListingDone(Self);
  324. end;
  325.  
  326. procedure TMFtpTreeView.SetWebStyle;
  327. begin
  328.    FWebStyle := W;
  329.  
  330.    if W then
  331.    begin
  332.       {$ifdef VER120}
  333.       HotTrack := True;
  334.       {$endif}
  335.       OnClick := NewOnClick;
  336.       OnDblClick := nil;
  337.    end
  338.    else
  339.    begin
  340.       {$ifdef VER120}
  341.       HotTrack := False;
  342.       {$endif}
  343.       OnClick := nil;
  344.       OnDblClick := NewOnClick;
  345.    end;
  346. end;
  347.  
  348. procedure TMFtpTreeView.NewOnClick;
  349. begin
  350.    if (Selected <> FCurrentDir) and (FFtp.Busy = False) then
  351.    begin
  352.       FFtp.Url := GetTreeNodeName(Selected);
  353.    end;
  354.  
  355.    inherited;
  356. end;
  357.  
  358. procedure TMFtpTreeView.NewOnEditing;
  359. begin
  360.    AllowEdit := True;
  361.  
  362.    if Item = FRoot then AllowEdit := False;
  363.  
  364.    inherited;
  365. end;
  366.  
  367. procedure TMFtpTreeView.NewOnCollapsing;
  368. begin
  369.    Flag := True;
  370. end;
  371.  
  372. procedure TMFtpTreeView.NewOnExpanding;
  373. begin
  374.    if not Flag then
  375.    begin
  376.       Node.Selected := True;
  377.  
  378.       if (Selected <> FCurrentDir) and (Node.HasChildren = True) and (Node.GetFirstChild = nil) and (FFtp.Busy = False) then
  379.       begin
  380.          FFtp.Url := GetTreeNodeName(Node);
  381.       end;
  382.    end;
  383.  
  384.    inherited;
  385. end;
  386.  
  387. procedure TMFtpTreeView.NewOnDirectoryChanged;
  388. var S: String;
  389. begin
  390.    S := FFtp.CurrentDirectory;
  391.    if S = '' then Exit; {Failure}
  392.  
  393.    if S[1] = '/' then
  394.    begin
  395.       if S = '/' then
  396.       begin
  397.          FCurrentDir := FRoot;
  398.          FCurrentDir.Selected := True;
  399.          Exit;
  400.       end
  401.       else
  402.       begin
  403.          System.Delete(S, 1, 1);
  404.       end;
  405.    end;
  406.  
  407.    Locate(S);
  408.    FCurrentDir.Selected := True;
  409. end;
  410.  
  411. procedure TMFtpTreeView.NewOnFtpInfo;
  412. var t: Integer;
  413.     S: String;
  414. begin
  415.    if info = ftpLoggedIn then
  416.    begin
  417.       with FFtp do
  418.       begin
  419.          S := BuildFTPTopURL(Server, Port, Username, Password);
  420.          t := FSiteInfo.RootInfoT.IndexOf(S);
  421.       end;
  422.  
  423.       if t >= 0 then
  424.       begin
  425.          FRoot := FSiteInfo.RootInfoP.Items[t];
  426.          if (FRoot = nil) or (TTreeNode(FSiteInfo.RootInfoP.Items[t]).Text = '') then
  427.          begin
  428.             FSiteInfo.Delete(t);
  429.             t := -1;
  430.          end;
  431.       end;
  432.  
  433.       if t < 0 then
  434.       begin
  435.          FRoot := Items.AddFirst(nil, 'ftp://' + FFtp.Server + '/');
  436.          with FRoot do
  437.          begin
  438.             ImageIndex := 2;
  439.             SelectedIndex := 2;
  440.             HasChildren := True;
  441.          end;
  442.  
  443.          FSiteInfo.Add(S, FRoot);
  444.  
  445.          Screen.Cursor := crAppStart;
  446.          PreloadDir('/', -1); {no level limitation}
  447.          Screen.Cursor := crDefault;
  448.       end;
  449.  
  450.       FRoot.Expand(False);
  451.       Locate(FFtp.CurrentDirectory);
  452.       FCurrentDir.Selected := True;
  453.  
  454.       Flag := False;
  455.       OnCollapsing := NewOnCollapsing;
  456.       OnExpanding := NewOnExpanding;
  457.    end;
  458. end;
  459.  
  460. procedure TMFtpTreeView.NewOnListingDone;
  461. var P: TTreeNode;
  462. begin
  463.    OnExpanding := nil;
  464.    Locate(FFtp.CurrentDirectory);
  465.  
  466.    P := FCurrentDir;
  467.    if not FFtp.FromCache then
  468.    begin
  469.       FCurrentDir.DeleteChildren;
  470.       PreloadDir(GetTreeNodeName(FCurrentDir), MAX_PRELOAD_LEVEL);
  471.    end;
  472.    FCurrentDir := P;
  473.  
  474.    UpdateView(FFtp.Directories);
  475.    if FCurrentDir.GetFirstChild = nil then
  476.       FCurrentDir.HasChildren := False
  477.    else
  478.    begin
  479.       FCurrentDir.HasChildren := True;
  480.       if not Flag then FCurrentDir.Expand(False);
  481.       Flag := False;
  482.    end;
  483.    Locate(FFtp.CurrentDirectory);
  484.    FCurrentDir.Selected := True;
  485.    OnExpanding := NewOnExpanding;
  486. end;
  487.  
  488. function TMFtpTreeView.GetTreeNodeName;
  489. var T: TTreeNode;
  490. begin
  491.    if N = FRoot then
  492.    begin
  493.       Result := N.Text;
  494.       Exit;
  495.    end;
  496.  
  497.    if N <> nil then
  498.    begin
  499.       T := N;
  500.       Result := T.Text + '/';
  501.       while T.Parent <> nil do
  502.       begin
  503.          T := T.Parent;
  504.          if T.Text[Length(T.Text)] = '/' then
  505.             Result := T.Text +  Result
  506.          else
  507.             Result := T.Text + '/' + Result;
  508.       end;
  509.       if T = FRoot then Exit;
  510.       if Copy(T.Text, 1, 6) = 'ftp://' then
  511.       begin
  512. //       FRoot.Collapse(True);
  513.          FRoot := T;
  514.          Exit;
  515.       end;
  516.    end;
  517.    Result := '';
  518. end;
  519.  
  520. procedure TMFtpTreeView.Locate;
  521. var i: Integer;
  522.     T, T1: TTreeNode;
  523.     S1: String;
  524. begin
  525.    T := FRoot;
  526.  
  527.    while (S <> '/') and (S <> '') do
  528.    begin
  529.       if S[1] = '/' then
  530.          System.Delete(S, 1, 1);
  531.  
  532.       i := Pos('/', S);
  533.       if i = 0 then
  534.       begin
  535.          i := Length(S);
  536.          S1 := Copy(S, 1, i);
  537.       end
  538.       else
  539.          S1 := Copy(S, 1, i - 1);
  540.  
  541.       if S1 = '' then Exit;
  542.  
  543.       T1 := IsTreeNodeExists(T, S1);
  544.       if T1 = nil then
  545.       begin
  546.          T := Items.AddChild(T, S1);
  547.          with T do
  548.          begin
  549.             ImageIndex := 1;
  550.             SelectedIndex := 0;
  551.             HasChildren := True;
  552.          end;
  553.       end
  554.       else
  555.          T := T1;
  556.       System.Delete(S, 1, i);
  557.    end;
  558.  
  559.    FCurrentDir := T;
  560. end;
  561.  
  562. function TMFtpTreeView.IsTreeNodeExists;
  563. begin
  564.    Result := nil;
  565.  
  566.    T := T.GetFirstChild;
  567.  
  568.    while T <> nil do
  569.    begin
  570.       if T.Text = C then
  571.       begin
  572.          Result := T;
  573.          Exit;
  574.       end;
  575.       T := T.GetNextSibling;
  576.    end;
  577. end;
  578.  
  579. procedure TMFtpTreeView.PreloadDir;
  580. var i, c, c1: Integer;
  581.     F: String;
  582.     T: TTreeNode;
  583.     DN, DN1: TStrings;
  584. begin
  585.    if (Level = 0) or (FPreload = False) then Exit;
  586.  
  587.    DN := TStringList.Create;
  588.  
  589.    i := Pos('ftp://' + FFtp.Server, S);
  590.    if i = 1 then System.Delete(S, 1, Length('ftp://' + FFtp.Server));
  591.  
  592.    Locate(S);
  593.  
  594.    try
  595.       with FFtp do
  596.       begin
  597.          F := GetCacheFilename(Server, UserName, S, Port, True);
  598.       end;
  599.  
  600.       if FileExists(F) then DN.LoadFromFile(F);   
  601.    except
  602.    end;
  603.  
  604.    if S = '/' then S := '';
  605.  
  606.    c1 := DN.Count - 1;
  607.  
  608.    if c1 > 4 then
  609.    begin
  610.       c := 1;
  611.  
  612.       DN1 := TStringList.Create;
  613.  
  614.       repeat
  615.          if (IsTreeNodeExists(FCurrentDir, DN[c]) = nil) then
  616.          begin
  617.             T := Items.AddChild(FCurrentDir, DN[c]);
  618.             with T do
  619.             begin
  620.                ImageIndex := 1;
  621.                SelectedIndex := 0;
  622.                if DN[c + 4] <> '' then
  623.                begin
  624.                   HasChildren := False;
  625.                   {$ifdef OVERLAY_MASK}
  626.                   OverlayIndex := 1;
  627.                   {$endif}
  628.                end
  629.                else
  630.                begin
  631.                   HasChildren := True;
  632.                end;
  633.             end;
  634.  
  635.             if S = '' then
  636.                DN1.Add(S + DN[c])
  637.             else
  638.                DN1.Add(S + '/' + DN[c]);
  639.          end;
  640.          Inc(c, 8);
  641.       until (c >= c1);
  642.  
  643.       if FCurrentDir.GetFirstChild = nil then
  644.          FCurrentDir.HasChildren := False
  645.       else
  646.          FCurrentDir.HasChildren := True;
  647.  
  648.       for i := 0 to DN1.Count - 1 do
  649.          PreloadDir(DN1[i], Level - 1);
  650.  
  651.       FreeAndNil(DN1);
  652.    end;
  653.    FreeAndNil(DN);
  654. end;
  655.  
  656. procedure TMFtpTreeView.UpdateView;
  657. var i: Integer;
  658.     T: TTreeNode;
  659. begin
  660.    for i := 0 to D.Count - 1 do
  661.    begin
  662.       if IsTreeNodeExists(FCurrentDir, D[i].Filename) = nil then
  663.       begin
  664.          T := Items.AddChild(FCurrentDir, D[i].Filename);
  665.          with T do
  666.          begin
  667.             ImageIndex := 1;
  668.             SelectedIndex := 0;
  669.             if D[i].SymbolLink <> '' then
  670.             begin
  671.                HasChildren := False;
  672.                {$ifdef OVERLAY_MASK}
  673.                OverlayIndex := 1;
  674.                {$endif}
  675.             end
  676.             else
  677.             begin
  678.                HasChildren := True;
  679.             end;
  680.          end;
  681.       end;
  682.    end;
  683.  
  684.    if FCurrentDir.GetFirstChild = nil then
  685.       FCurrentDir.HasChildren := False
  686.    else
  687.       FCurrentDir.HasChildren := True;
  688. end;
  689.  
  690. procedure TMFtpTreeView.CollapseAll;
  691. var i: Integer;
  692. begin
  693.    for i := 0 to Items.Count - 1 do
  694.    begin
  695.       if Items[i].Parent = nil then Items[i].Collapse(True);
  696.    end;
  697. end;
  698.  
  699. procedure TMFtpTreeView.ExpandAll;
  700. var i: Integer;
  701. begin
  702.    Flag := True;
  703.    for i := 0 to Items.Count - 1 do
  704.    begin
  705.       if Items[i].Parent = nil then Items[i].Expand(True);
  706.    end;
  707.    FRoot.Selected := True;   
  708.    Flag := False;
  709. end;
  710.  
  711. constructor TMFtpSiteInfo.Create;
  712. begin
  713.    inherited Create;
  714.  
  715.    FRootInfoT := TStringList.Create;
  716.    FRootInfoP := TList.Create;
  717.  
  718.    FTreeView := AOwner;
  719.    FCount := 0;
  720. end;
  721.  
  722. destructor TMFtpSiteInfo.Destroy;
  723. begin
  724.    FreeAndNil(FRootInfoT);
  725.    FreeAndNil(FRootInfoP);
  726.  
  727.    inherited Destroy;
  728. end;
  729.  
  730. procedure TMFtpSiteInfo.Add;
  731. begin
  732.    FRootInfoT.Add(TopURL);
  733.    FRootInfoP.Add(TN);
  734.    Inc(FCount);
  735. end;
  736.  
  737. procedure TMFtpSiteInfo.Clear;
  738. var i: Integer;
  739. begin
  740.    for i :=0 to FRootInfoP.Count - 1 do
  741.       FTreeView.Items.Delete(FRootInfoP.Items[i]);
  742.  
  743.    FRootInfoT.Clear;
  744.    FRootInfoP.Clear;
  745.    FCount := 0;
  746. end;
  747.  
  748. procedure TMFtpSiteInfo.Delete(TN: TTreeNode);
  749. var i: Integer;
  750. begin
  751.    for i := 0 to FRootInfoP.Count - 1 do
  752.    begin
  753.       if FRootInfoP.Items[i] = TN then
  754.       begin
  755.          FTreeView.Items.Delete(TN);
  756.          FRootInfoT.Delete(i);
  757.          FRootInfoP.Delete(i);
  758.          Dec(FCount);
  759.       end;
  760.    end;
  761. end;
  762.  
  763. procedure TMFtpSiteInfo.Delete(N: Integer);
  764. begin
  765.    FRootInfoT.Delete(N);
  766.    FRootInfoP.Delete(N);
  767.    Dec(FCount);
  768. end;
  769.  
  770. end.
  771.  
  772.