找传奇、传世资源到传世资源站!

Pascal 局域网共享资源 源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

【例子介绍】带源代码的局域网共享资源浏览器
【相关图片】 暂无

【源码结构】

unit Main;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ToolWin, ComCtrls, ExtCtrls, Menus, StdCtrls, Tabs, ImgList,Inifiles,
  Buttons,ShlObj,MultiSearchThreadUnit,ShellApi;

type
  TMainForm = class(TForm)
    ToolPanel: TPanel;
    CoolBar1: TCoolBar;
    BottomPanel: TPanel;
    Splitter1: TSplitter;
    MainMenu: TMainMenu;
    MenuMain: TMenuItem;
    MenuAbout: TMenuItem;
    StatusBar: TStatusBar;
    Splitter2: TSplitter;
    BottomDockPanel: TPanel;
    Splitter3: TSplitter;
    ImageList1: TImageList;
    LeftPanel: TPanel;
    LeftDockPanel: TPanel;
    LeftPageCtrl: TPageControl;
    SearchTabSheet: TTabSheet;
    SearchTree: TTreeView;
    FavoTabSheet: TTabSheet;
    FavoTree: TTreeView;
    RightPanel: TPanel;
    RightDockPanel: TPanel;
    RightPageCtrl: TPageControl;
    QucikViewTab: TTabSheet;
    BtnNewDock: TSpeedButton;
    FolderTabSheet: TTabSheet;
    ShareListView: TListView;
    FolderListView: TListView;
    ListViewPopupMenu: TPopupMenu;
    N_Open: TMenuItem;
    N_Copy: TMenuItem;
    N_Size: TMenuItem;
    N_OpenWithNotpad: TMenuItem;
    N1: TMenuItem;
    N_Refresh: TMenuItem;
    N_Favorite: TMenuItem;
    N_NewWin: TMenuItem;
    BtnFindComputer: TSpeedButton;
    ClientPanel: TPanel;
    ClientPageCtrl: TPageControl;
    ShareTabSheet: TTabSheet;
    BrowseListView: TListView;
    InfoPanel: TPanel;
    BottomPageCtrl: TPageControl;
    AllFileTabSheet: TTabSheet;
    AllListBox: TListBox;
    FindTabSheet: TTabSheet;
    FindListView: TListView;
    Mp3TabSheet: TTabSheet;
    Mp3ListView: TListView;
    MovieTabSheet: TTabSheet;
    MovieListView: TListView;
    BtnDOS: TSpeedButton;
    BtnConfigor: TSpeedButton;
    N_CopyTo: TMenuItem;
    BtnRefreshTree: TSpeedButton;
    BottomPopupMenu: TPopupMenu;
    N_SaveAll: TMenuItem;
    SaveDlg: TSaveDialog;
    MenuView: TMenuItem;
    Menu_Tree: TMenuItem;
    Menu_Folder: TMenuItem;
    Menu_Result: TMenuItem;
    BtnAutoSearch: TSpeedButton;
    LanExplorer1: TMenuItem;
    BtnPause: TSpeedButton;
    BtnStop: TSpeedButton;
    FavoTreePopupMenu: TPopupMenu;
    N_DeleteFavo: TMenuItem;
    IconCheckBox: TCheckBox;
    N_BottomOpen: TMenuItem;
    N_BottomCopy: TMenuItem;
    N_BottomCopyTo: TMenuItem;
    N_BottomFileSize: TMenuItem;
    N_Property: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure LeftDockPanelStartDock(Sender: TObject;
      var DragObject: TDragDockObject);
    procedure LeftDockPanelEndDock(Sender, Target: TObject; X, Y: Integer);
    procedure RightDockPanelStartDock(Sender: TObject;
      var DragObject: TDragDockObject);
    procedure RightDockPanelEndDock(Sender, Target: TObject; X,
      Y: Integer);
    procedure BottomDockPanelStartDock(Sender: TObject;
      var DragObject: TDragDockObject);
    procedure BottomDockPanelEndDock(Sender, Target: TObject; X, Y: Integer);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BtnNewDockClick(Sender: TObject);
    procedure ShareListViewClick(Sender: TObject);
    procedure ShareListViewSelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    procedure FolderListViewClick(Sender: TObject);
    procedure RightPageCtrlChange(Sender: TObject);
    procedure ClientPageCtrlChange(Sender: TObject);
    procedure N_OpenClick(Sender: TObject);
    procedure N_CopyClick(Sender: TObject);
    procedure ListViewPopupMenuPopup(Sender: TObject);
    procedure N_SizeClick(Sender: TObject);
    procedure N_OpenWithNotpadClick(Sender: TObject);
    procedure N_NewWinClick(Sender: TObject);
    procedure N_FavoriteClick(Sender: TObject);
    procedure SearchTreeClick(Sender: TObject);
    procedure FavoTreeClick(Sender: TObject);
    procedure BtnFindComputerClick(Sender: TObject);
    procedure BtnDOSClick(Sender: TObject);
    procedure BtnConfigorClick(Sender: TObject);
    procedure N_RefreshClick(Sender: TObject);
    procedure N_CopyToClick(Sender: TObject);
    procedure BtnRefreshTreeClick(Sender: TObject);
    procedure N_SaveAllClick(Sender: TObject);
    procedure Menu_TreeClick(Sender: TObject);
    procedure Menu_FolderClick(Sender: TObject);
    procedure Menu_ResultClick(Sender: TObject);
    procedure BtnAutoSearchClick(Sender: TObject);
    procedure LanExplorer1Click(Sender: TObject);
    procedure BtnPauseClick(Sender: TObject);
    procedure BtnStopClick(Sender: TObject);
    procedure N_DeleteFavoClick(Sender: TObject);
    procedure FavoTreePopupMenuPopup(Sender: TObject);
    procedure IconCheckBoxClick(Sender: TObject);
    procedure AllListBoxDblClick(Sender: TObject);
    procedure FindListViewDblClick(Sender: TObject);
    procedure Mp3ListViewDblClick(Sender: TObject);
    procedure MovieListViewDblClick(Sender: TObject);
    procedure N_BottomOpenClick(Sender: TObject);
    procedure N_BottomCopyClick(Sender: TObject);
    procedure BottomPopupMenuPopup(Sender: TObject);
    procedure N_BottomFileSizeClick(Sender: TObject);
    procedure N_BottomCopyToClick(Sender: TObject);
    procedure StatusBarMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormResize(Sender: TObject);
    procedure N_PropertyClick(Sender: TObject);
  private
    { Private declarations }
    ini:    Tinifile;
    f: textfile;
    TabSheetX: TTabSheet;
    CurListView: TListView;
    CurDirName,CurGroupName:string;
    CurRlistItem:TListItem;
    TemTreeNode:TTreeNode;
    CurBottomListView:TListView;
    FOldProc1,FOldProc2,FOldProc3 : TWndMethod;

    procedure OpenIni;
    procedure SaveIni;
    procedure OpenFavorite;
    procedure SaveFavorite;
    procedure MyListViewClick(Sender: TObject);
    procedure LanTreeClick(LanTree:TTreeView);
    procedure MyBottomListViewClick(ListView:TListView);
    procedure DockHostClick(Sender: TObject);
    Procedure MyEndDock;
    procedure MyDockCloseProc1(var message : TMessage);
    procedure MyDockCloseProc2(var message : TMessage);
    procedure MyDockCloseProc3(var message : TMessage);
  public
    { Public declarations }
    OldFileCount:integer;
    StrListAll,StrListSearch,StrListMp3,StrListMovie:TStringList;
    procedure BringFront;
    procedure CheckFile(FileName,MyDir,MyGroup:string;ImageIndex:integer);
  end;

type FileType = (IsFile, IsDir);
type OwnerType = (InTreeView,InListView);

type
  PMyTreeItem = ^TMyTreeItem;
  TMyTreeItem = record
    DirName,Group: string;
    TabIndex: integer;
    MyClientListView:TListView;
    MyRightListItem:TListItem;
  end;

type
  PListItem = ^TMyListItem;
  TMyListItem = record
   //dirName,group: string;
   index,count: integer;
  end;

type
  pTabData = ^TMyTabData;
  TMyTabData=record
    MyGroup,MyDir:string;
    MyRListItem:TListItem;
  end;

TExecuteThread=class(TThread)
 private
 exeFile,exeDir:string;
 protected
 procedure Execute; override;
  //Procedure Adddir;
 end;

var
  MainForm: TMainForm;

  AppDir:       String;
  GroupList:    array[0..500]of string;
  GroupNum,ver,SearchBeginNum,FinishNum,ThreadNum:integer;
  CanOpen:      Boolean;
  MyItemPtr:    PMyTreeItem;
  ListItemPtr:  PListItem;
  TabDataPtr:      pTabData;
  recursive,stop,bAutoSearch,bSysIcon:    boolean;
  MainSearch:TMainThread;

implementation
uses GetDomainThreadUnit,SearchGroupThreadUnit,SearchHostThreadUnit,
     SearchDirThreadunit,ConFigor,FmxUtils,CopyTo,About;
{$R *.DFM}

procedure TExecuteThread.Execute;
begin
 ExecuteFile(exefile,'',exedir,SW_SHOW);
end;

procedure TMainForm.MyDockCloseProc1(var message: TMessage);
begin
  if (message.Msg = WM_SYSCOMMAND) and (message.WParam = SC_CLOSE) then
    Menu_Tree.Checked := false;
  FOldProc1(message);
end;

procedure TMainForm.MyDockCloseProc2(var message: TMessage);
begin
  if (message.Msg = WM_SYSCOMMAND) and (message.WParam = SC_CLOSE) then
    Menu_Folder.Checked := false;
  FOldProc2(message);
end;

procedure TMainForm.MyDockCloseProc3(var message: TMessage);
begin
  if (message.Msg = WM_SYSCOMMAND) and (message.WParam = SC_CLOSE) then
    Menu_Result.Checked := false;
  FOldProc3(message);
end;

procedure TMainForm.DockHostClick(Sender: TObject);
begin
  //LeftPanel.visible:=LeftDockPanel.Visible;
  if LeftPanel.VisibleDockClientCount=0 then LeftPanel.Hide else LeftPanel.Show;
  if RightPanel.VisibleDockClientCount=0 then RightPanel.Hide else RightPanel.Show;
  if BottomPanel.VisibleDockClientCount=0 then BottomPanel.Hide else BottomPanel.Show;
  {if LeftDockPanel.HostDockSite.DockClientCount=1
  then LeftDockPanel.HostDockSite.Visible:= LeftDockPanel.Visible;}
  Menu_Tree.Checked := LeftDockPanel.Visible;
  Menu_Folder.Checked := RightDockPanel.Visible;
  Menu_Result.Checked := BottomDockPanel.Visible;
end;

Procedure TMainForm.MyEndDock;
begin

  if (LeftPanel.VisibleDockClientCount=0) then
  begin
    LeftPanel.Visible := false;
    Splitter2.Visible := false;
  end
  else
  begin
    LeftPanel.Visible := true;
    Splitter2.Visible := true;
    Splitter2.Align := alRight;
    Splitter2.Align := alLeft;
  end;

  if (BottomPanel.VisibleDockClientCount=0) then
  begin
    BottomPanel.Visible := false;
    Splitter1.Visible := false;
  end
  else
  begin
    BottomPanel.Visible := true;
    Splitter1.Visible := true;
    Splitter1.Align := alTop;
    Splitter1.Align := alBottom;
  end;

  if (RightPanel.VisibleDockClientCount=0) then
  begin
    RightPanel.Visible := false;
    Splitter3.Visible := false;
  end
  else
  begin
    RightPanel.Visible := true;
    Splitter3.Visible := true;
    Splitter3.Align := alRight;
  end;
  
end;

procedure TMainForm.CheckFile(FileName,MyDir,MyGroup:string;ImageIndex:integer);
var listitem:TListitem;
begin
  with ConfigorForm do
    begin

     if CheckDest(FileName) then
     begin
       listitem:=FindListview.Items.Add;
       listitem.ImageIndex := ImageIndex;
       listitem.Caption := extractfilename(FileName);
       listitem.SubItems.add(MyDir);
       listitem.SubItems.add(MyGroup);
       StrListSearch.Add(' 工作组:' MyGroup ' 地址:' MyDir '\' FileName);
     end;

     if CheckMP3(FileName) then
     begin
       listitem:=MP3Listview.Items.Add;
       listitem.ImageIndex := ImageIndex;
       listitem.Caption := extractfilename(FileName);
       listitem.SubItems.add(MyDir);
       listitem.SubItems.add(MyGroup);
       StrListMp3.Add(' 工作组:' MyGroup ' 地址:' MyDir '\' FileName);
     end;

     if CheckMovie(FileName) then
     begin
       listitem:=MovieListview.Items.Add;
       listitem.ImageIndex := ImageIndex;
       listitem.Caption := extractfilename(FileName);
       listitem.SubItems.add(MyDir);
       listitem.SubItems.add(MyGroup);
       StrListMovie.Add(' 工作组:' MyGroup ' 地址:' MyDir '\' FileName);
     end;

  end;
end;

procedure TMainForm.OpenIni;
begin

  ini:=Tinifile.create(AppDir 'LanExplorer.ini');
  if not fileexists('LanExplorer.ini')
  then
  begin
    ini.writeInteger('window position','top',top);
    ini.writeInteger('window position','left',left);
    ini.writeInteger('window position','width',width);
    ini.writeInteger('window position','height',height);

    ini.writeString('Dock','RightDockPanel','alRight');
    //ini.writeString('IP','IP2',Edit2.Text);
  end
  else
  begin
    top:=ini.ReadInteger('window position','top',50);
    left:=ini.ReadInteger('window position','left',50);
    width:=ini.ReadInteger('window position','width',500);
    height:=ini.ReadInteger('window position','height',50);

    if (width=screen.Width)and(height=screen.Height)then WindowState:=wsMaximized; 

    if ini.ReadString('Dock','RightDockPanel','alRight')='alLeft'
    then BtnNewDockClick(Self);
    //Edit2.Text:=ini.ReadString('IP','IP2',Edit2.Text);
  end;
  ini.Free;
  
  
end;

procedure TMainForm.SaveIni;
begin

  if AppDir[1]='\' then exit; //open on the LAN
  //showmessage(mydir);
  ini:=Tinifile.create(AppDir 'LanExplorer.ini');

  ini.writeInteger('window position','top',top);
  ini.writeInteger('window position','left',left);
  ini.writeInteger('window position','width',width);
  ini.writeInteger('window position','height',height);

  if RightDockPanel.HostDockSite = LeftPanel then
  ini.writeString('Dock','RightDockPanel','alLeft')
  else ini.writeString('Dock','RightDockPanel','alRight');
  
  //ini.writeString('IP','IP2',Edit2.Text);

  ini.Free;
  
end;

procedure TMainForm.OpenFavorite;
var RootNode,TemNode:TTreeNode;
    fg,fs:string;
begin

   RootNode:=FavoTree.Items[0];
   if fileexists('Favorite.txt') then
   begin
     assignfile(f,'Favorite.txt');
     reset(f);
     while not eof(f) do
     begin
          readln(f,fg);
          New(MyItemPtr);
          MyItemPtr^.group := fg;

          readln(f,fs);
          MyItemPtr^.dirName := fs;

          {ListItem:=ListView7.Items.Insert(0);
          listitem.Caption := fs;
          listitem.SubItems.Text := fg;}

          TemNode:=FavoTree.Items.AddChild(RootNode,fs);
          TemNode.Data := MyItemPtr;
     end;
     closefile(f);
     //FavTree.LoadfromFile('Favorite.txt');
     try
     FavoTree.Items[0].Expand(false);
     except on ETreeViewError do
       begin
         FavoTree.Items.AddChildFirst(nil,'收藏');
       end;
     end; //end of try
   end;

end;

procedure TMainForm.SaveFavorite;
var i:integer;
    TempNode:TTreeNode;
begin
  if AppDir[1]<>'\' then     //open on the LAN
  if FavoTree.Items[0].HasChildren  then
  begin
    tempNode:=nil; // just remove warning;
    assignfile(f,AppDir '\Favorite.txt');
    rewrite(f);
    for i:=1 to FavoTree.Items[0].count do
    begin
    tempNode:= FavoTree.Items[0].Item[i-1];
    writeln(f,trimright(pMyTreeItem(tempNode.data)^.group));
    writeln(f,tempNode.text);
    end;
    closefile(f);
    caption:=tempNode.text; // just remove warning;
  end;
end;

procedure TMainForm.BringFront;
begin
  Application.BringToFront;
end;

procedure TMainForm.MyListViewClick(Sender: TObject);
var DirName,extn,FileName,GroupName:string;
    DirSearcher:TSearchDirThread;
    Exe: TExecuteThread;
    newListItem,RunItem:Tlistitem;
    TemListView:TListView;
begin

  RunItem:= (Sender as TListView).Selected;
  if (RunItem=nil) then exit;
  
  FileName:= RunItem.Caption;
 
  DirName:=pTabData(ClientPageCtrl.ActivePage.Tag).MyDir;

  GroupName:=pTabData(ClientPageCtrl.ActivePage.Tag).MyGroup;
  if GroupName[length(GroupName)]=#0
  then delete(GroupName,length(GroupName),1);

  //caption:= dirname '\' filename;
  if (Sender as TListView).Selected.ImageIndex=0 then //folder
  begin
    tabsheetx:=ttabsheet.Create(Self);
    tabsheetx.PageControl := ClientPageCtrl;
    DirName:=DirName '\' FileName;
    tabsheetx.Caption := DirName;
    tabsheetx.Repaint;
    
    TemListView:=TListView.Create(tabsheetx);
    with TemListView do
    begin
      Parent := tabsheetx;
      Align := alclient;
      Visible := true;
      OnDblClick := MyListviewClick;
      PopupMenu := ListViewPopupMenu;
      //OnMOuseDown := RMouseDownHandler;
      ViewStyle := vssmallicon;
      SmallImages := imagelist1;
      MultiSelect := true;
    end;
  ClientPageCtrl.ActivePageIndex :=tabsheetx.TabIndex;
  RightPageCtrl.ActivePageIndex:=1;
  DirSearcher:=TSearchDirThread.create(true);
  DirSearcher.mydir := DirName;
  //DirSearcher.mygroup := groupname;
  DirSearcher.myList := TemListView;
  DirSearcher.Rlist :=FolderListView;
  //DirSearcher.myTree := Treeview1;
  //DirSearcher.ButtonListbox := Listbox9;
  newListItem:=FolderListview.Items.Insert(0);
  newListItem.Caption := extractfilename(DirSearcher.mydir);
  new(ListItemPtr);
  ListItemPtr.index := TabSheetX.TabIndex;
  NewListItem.data:= ListItemPtr;
  NewListItem.SubItems.Add(DirName);
  NewListItem.SubItems.Add(GroupName);
  NewListItem.ImageIndex := 6;

  new(TabDataPtr);
  TabDataPtr.MyGroup := GroupName;
  TabDataPtr.MyDir := DirName;
  TabDataPtr.MyRListItem :=NewListItem;
  TabSheetX.Tag := integer(TabDataPtr);

  DirSearcher.RListItem := NewListItem;
  DirSearcher.ClickType := InListView;
  DirSearcher.FreeOnTerminate := true;
  DirSearcher.Resume;
 end
 //****************************
 else
 begin
  extn:=lowercase(ExtractFileExt(filename));

  if not bSysIcon then
    //if extn<>'.exe' then runItem.ImageIndex := 17 else runItem.ImageIndex:=18;
    if extn<>'.exe' then
    begin
      if runItem.ImageIndex=1 then runItem.ImageIndex := 17
      else runItem.ImageIndex:=1;
    end
    else
    begin
      if runItem.ImageIndex=2 then runItem.ImageIndex:=18
      else  runItem.ImageIndex:=2;
    end;

  Exe:=TExecuteThread.Create(true);
  Exe.exeFile := DirName '\' filename;
  Exe.exeDir := DirName;
  Exe.FreeOnTerminate := true;
  Exe.Resume;
  //ExecuteFile(dir '\' filename,'',dir,SW_SHOW);
 end;
 //end;
end;

procedure TMainForm.FormCreate(Sender: TObject);
var GetDomainThread:TGetDomainThread;
begin

  AppDir:=ExtractFilePath(ParamStr(0));

  //ButtomRightPanel.BevelOuter:=bvNone;
  //DockPanel.BevelOuter:=bvNone;
  LeftPanel.BevelOuter:=bvNone;
  RightPanel.BevelOuter:=bvNone;
  BottomPanel.BevelOuter:=bvNone;
  LeftPanel.OnClick := DockHostClick;
  RightPanel.OnClick := DockHostClick;
  BottomPanel.OnClick := DockHostClick;

  {LeftPanel.AutoSize := true;
  RightPanel.AutoSize := true;
  BottomPanel.AutoSize := true;}

  BottomDockPanel.manualdock(nil);
  BottomDockPanel.manualdock(BottomPanel);
  //ButtomRightPanel.manualdock(BottomPanel);
  //ClientPageCtrl.ManualDock(Self);

  LeftDockPanel.manualdock(nil);
  LeftDockPanel.manualdock(LeftPanel);

  RightDockPanel.manualdock(nil);
  RightDockPanel.manualdock(RightPanel);

  StrListAll:=TStringList.Create;
  StrListSearch:=TStringList.Create;
  StrListMp3:=TStringList.Create;
  StrListMovie:=TStringList.Create;

  GroupNum:=0;
  FinishNum:=0;
  ThreadNum:=3;
  CanOpen:=false;
  OldFileCount:=0;
  GetDomainThread:=TGetDomainThread.Create(true);
  GetDomainThread.LanTree := SearchTree;
  GetDomainThread.Resume;

  recursive:=false;
  stop:=false;
  bAutoSearch:=true;

  OpenIni;
  OpenFavorite;

  BrowseListView.OnDblClick := MyListViewClick;

  new(TabDataPtr);
  TabDataPtr.MyGroup := '';
  TabDataPtr.MyDir := '';
  TabDataPtr.MyRListItem := nil;
  ShareTabSheet.Tag := integer(TabDataPtr);

end;

procedure TMainForm.LeftDockPanelStartDock(Sender: TObject;
  var DragObject: TDragDockObject);
begin
  LeftPanel.Visible := true;
  {LeftPanel.AutoSize := false;
  LeftPanel.Width := 200;}
end;

procedure TMainForm.LeftDockPanelEndDock(Sender, Target: TObject; X,
  Y: Integer);
begin

  if Target is TCustomDockForm then
  begin
    FOldProc1 := (Target as TCustomDockForm).WindowProc;
    (Target as TCustomDockForm).WindowProc := MyDockCloseProc1;
  end;

  MyEndDock;
  

end;

procedure TMainForm.RightDockPanelStartDock(Sender: TObject;
  var DragObject: TDragDockObject);
begin
  {RightPanel.AutoSize := false;
  RightPanel.Width:=160; }
  RightPanel.Visible := true;
end;

procedure TMainForm.RightDockPanelEndDock(Sender, Target: TObject; X,
  Y: Integer);
begin

  if Target is TCustomDockForm then
  begin
    FOldProc2 := (Target as TCustomDockForm).WindowProc;
    (Target as TCustomDockForm).WindowProc := MyDockCloseProc2;
  end;
  MyEndDock;


end;

procedure TMainForm.BottomDockPanelStartDock(Sender: TObject;
  var DragObject: TDragDockObject);
begin
  {BottomPanel.AutoSize := false;
  BottomPanel.Height:=102;}
  BottomPanel.Visible := true;
  {BottomPanel.Align := altop;
  BottomPanel.Align := alBottom;}
  
end;

procedure TMainForm.BottomDockPanelEndDock(Sender, Target: TObject; X,
  Y: Integer);
begin

  if Target is TCustomDockForm then
  begin
    FOldProc3 := (Target as TCustomDockForm).WindowProc;
    (Target as TCustomDockForm).WindowProc := MyDockCloseProc3;
  end;
  MyEndDock;


end;

procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  SaveIni;
  SaveFavorite;
  
end;

procedure TMainForm.BtnNewDockClick(Sender: TObject);
begin

    RightDockPanel.manualdock(LeftPanel,nil,alBottom);
    RightPanel.Visible := false;
    Splitter3.Visible := false;
    {RightDockPanel.Height := (LeftPanel.Height div 3);
    RightDockPanel.Align := alBottom;
    LeftDockPanel.Height:=LeftPanel.Height-RightDockPanel.Height;
    RightDockPanel.Color := clred;}
    BtnNewDock.Down := true;
  
end;

procedure TMainForm.LanTreeClick(LanTree:TTreeView);
var GroupSearcher: TSearchGroupThread;
    HostSearcher:TSearchHostThread;
    DirSearcher:TSearchDirThread;
    Exe: TExecuteThread;
    TemListView:TListView;
    ListItem:TListItem;
    TemDirName:string;
    //i:integer;
begin

  if (LanTree.Selected = nil)or(LanTree.Selected = LanTree.Items[0]) then exit;

  case LanTree.Selected.ImageIndex of
  5,14:    //workgroup
  begin
    LanTree.Selected.ImageIndex := 16;
    LanTree.Selected.SelectedIndex := 16;
    GroupSearcher:=TSearchGroupThread.create(true);
    GroupSearcher.MyTree := LanTree;
    GroupSearcher.MyGroup := LanTree.Selected.Text;
    GroupSearcher.MyNode := LanTree.Selected;
    GroupSearcher.FreeOnTerminate := true;
    GroupSearcher.Resume;
  end;
  7,15,27:    //host
  begin
    LanTree.Selected.ImageIndex := 12;
    LanTree.Selected.SelectedIndex := 12;
    LanTree.selected.StateIndex := -1;
    LanTree.SetFocus;
    HostSearcher:=TSearchHostThread.create(true);
    HostSearcher.MyHost := LanTree.Selected.Text;
    HostSearcher.MyGroup := LanTree.Selected.Parent.Text;
    HostSearcher.MyTree:=LanTree;
    HostSearcher.MyNode:=LanTree.selected;
    HostSearcher.FreeOnTerminate := true;
    HostSearcher.Resume;
    //explordir.WaitFor;
  end;
  0,19,30: //closed folder
  begin
    LanTree.Selected.ImageIndex := 6;
    LanTree.Selected.SelectedIndex :=6;
    LanTree.selected.StateIndex := -1;
    CoolBar1.SetFocus;
    TabSheetX:=TTabSheet.Create(self);
    TabSheetX.PageControl := ClientPageCtrl;
    TemDirName:=pMyTreeItem(LanTree.Selected.data)^.dirname;
    if TemDirName[length(TemDirName)]='\'
    then delete(TemDirName,length(TemDirName),1);
    TabSheetX.Caption :=TemDirName;
    TabSheetX.Repaint;
    TemListView:=TListView.Create(tabsheetx);
    TemListView.Parent := tabsheetx;
    TemListView.Align := alclient;
    TemListView.Visible := true;
    pMyTreeItem(LanTree.Selected.data)^.MyClientListView := TemListView;
    TemListView.OnDblClick := MyListViewClick;
    //TemListView.OnMOuseDown := RMouseDownHandler;
    TemListView.PopupMenu := ListViewPopupMenu;
    TemListView.ViewStyle := vssmallicon;
    TemListView.SmallImages := imagelist1;
    TemListView.MultiSelect := true;
    ClientPageCtrl.ActivePage :=TabSheetX;
    DirSearcher:=TSearchDirThread.create(true);
    DirSearcher.ClickType:=InTreeView;
    DirSearcher.mydir := TemDirName;
    DirSearcher.mygroup:= pMyTreeItem(LanTree.Selected.data)^.group;
    DirSearcher.myList := TemListView;
    DirSearcher.Rlist := FolderListview;
    DirSearcher.myTree := LanTree;
    DirSearcher.mynode := LanTree.Selected;
    ListItem:=FolderListview.Items.Insert(0);
    DirSearcher.RListItem := ListItem;
    ListItem.Caption := extractfilename(DirSearcher.mydir);
    ListItem.SubItems.Add(TemDirName);
    ListItem.SubItems.Add(DirSearcher.mygroup);
    //ListItem.SubItems[0] := TemDirName;
    //ListItem.SubItems[1] := DirSearcher.mygroup;

    new(TabDataPtr);
    TabDataPtr.MyGroup := DirSearcher.mygroup;
    if TabDataPtr.MyGroup[length(TabDataPtr.MyGroup)]=#0
    then delete(TabDataPtr.MyGroup,length(TabDataPtr.MyGroup),1);
    TabDataPtr.MyDir := DirSearcher.MyDir;
    TabDataPtr.MyRListItem := DirSearcher.RListItem;
    TabSheetX.Tag := integer(TabDataPtr);

    ListItem.ImageIndex := 6;
    new(ListItemPtr);
    ListItemPtr.index := TabSheetX.TabIndex;
    ListItem.data:= ListItemPtr;
    RightPageCtrl.ActivePageIndex:=1;
    pMyTreeItem(LanTree.Selected.data)^.MyRightListItem := ListItem;
    pMyTreeItem(LanTree.Selected.data)^.tabindex:=TabSheetX.TabIndex;
    DirSearcher.FreeOnTerminate := true;
    DirSearcher.Resume;
    //DirSearcher.WaitFor;
  end;
  10,6: // openfolder;
  begin
    ClientPageCtrl.ActivePageIndex := pMyTreeItem(LanTree.Selected.data)^.tabindex;
    //caption:= inttostr(pMyTreeItem(tree2.Selected.data)^.tabindex);
    RightPageCtrl.ActivePageIndex:=1;
  end;
  11,31:
  begin  //try to open a folder that can't open before or originally empty
    LanTree.Selected.ImageIndex := 6;
    LanTree.Selected.SelectedIndex := 6;
    LanTree.selected.StateIndex := -1;
    //checkbox2.SetFocus;
    ClientPageCtrl.ActivePageIndex := pMyTreeItem(LanTree.Selected.data)^.tabindex;
    DirSearcher:=TSearchDirThread.create(true);
    DirSearcher.mydir := pMyTreeItem(LanTree.Selected.data)^.dirname;
    //i:=pMyTreeItem(LanTree.Selected.data)^.tabindex;
    DirSearcher.myList := pMyTreeItem(LanTree.Selected.data)^.MyClientListView;
    DirSearcher.Rlist := FolderListview;
    DirSearcher.myTree := LanTree;
    ListItem:=pMyTreeItem(LanTree.Selected.data)^.MyRightListItem;
    ListItem.Caption := extractfilename(DirSearcher.mydir);
    ListItem.ImageIndex := 6;
    DirSearcher.RListItem := ListItem;
    DirSearcher.mygroup := ListItem.SubItems.Text;
    //listbox7.Items[listbox7.Items.count-i]:=('重新搜索:' DirSearcher.mydir);
    DirSearcher.mynode := LanTree.Selected;
    DirSearcher.ClickType:= InTreeView;
    DirSearcher.FreeOnTerminate := true;
    DirSearcher.Resume;
    RightPageCtrl.ActivePageIndex:=1;
  end;
  20,21:  // locked folder
  begin
    LanTree.Selected.ImageIndex := 21;
    LanTree.Selected.SelectedIndex := 21;
    Exe:=TExecuteThread.Create(true);
    Exe.exeFile := pMyTreeItem(LanTree.Selected.data)^.dirname;
    Exe.exeDir := extractfilepath(Exe.exeFile);
    //caption:=exe.exeFile;
    Exe.FreeOnTerminate := true;
    Exe.Resume;
  end;
  26,28: // win2000 or nt ,guest forbided ,need login
  begin
    if LanTree.Selected.ImageIndex = 26
    then
    begin
      LanTree.Selected.ImageIndex := 28;
      LanTree.Selected.SelectedIndex := 28;
    end
    else
    begin
      LanTree.Selected.ImageIndex := 26;
      LanTree.Selected.SelectedIndex := 26;
    end;
    
    Exe:=TExecuteThread.Create(true);
    Exe.exeFile := LanTree.Selected.Text;
    //showmessage(exe.exefile);
    Exe.exeDir := extractfilepath(Exe.exeFile);
    //caption:=exe.exeFile;
    Exe.FreeOnTerminate := true;
    Exe.Resume;
  end;
 end; //end of case

end;

procedure TMainForm.ShareListViewClick(Sender: TObject);
var ListIndex,ListCount,i:integer;
    ListItem:TListItem;
    str:string;
begin

  if ShareListView.Selected=nil then exit;
  ClientPageCtrl.ActivePageIndex :=0;
  ListIndex:=PListitem(ShareListView.Selected.Data)^.index;
  ListCount:=PListitem(ShareListView.Selected.Data)^.Count;
  AllListBox.TopIndex := AllListBox.Items.Count-ListIndex;

  //ShareTabSheet.Caption := ShareListView.Selected.SubItems[0];
  pTabData(ShareTabSheet.Tag).MyDir:= ShareListView.Selected.SubItems[0];
  pTabData(ShareTabSheet.Tag).MyGroup:= ShareListView.Selected.SubItems[1];
  pTabData(ShareTabSheet.Tag).MyRListItem:= ShareListView.Selected;

  InfoPanel.Caption := '主机和文件夹:' ShareListView.Selected.SubItems[0] 
                       '  工作组:'  ShareListView.Selected.SubItems[1];
  BrowseListView.Items.Clear;
  //RightPageCtrl.ActivePage := BrowseTabsheet;
  for i:= 1 to ListCount do
  begin
    //ResultListBox.Items.Add(AllListBox.Items[i]);
    ListItem:=BrowseListView.Items.Add;
    str:= AllListBox.Items[AllListBox.Items.Count-ListIndex i-1];
    if str[length(str)]='\' then
    begin
      ListItem.ImageIndex :=0;
      delete(str,length(str),1);
    end
    else ListItem.ImageIndex :=1;
    listitem.Caption := extractfilename(str);
  end;
  
end;

procedure TMainForm.ShareListViewSelectItem(Sender: TObject;
  Item: TListItem; Selected: Boolean);
begin
  ShareListViewClick(Self);
end;

procedure TMainForm.FolderListViewClick(Sender: TObject);
begin

  if FolderListView.Selected=nil then exit;
  ClientPageCtrl.ActivePageIndex :=PListitem(FolderListView.Selected.Data)^.index;

end;

procedure TMainForm.RightPageCtrlChange(Sender: TObject);
begin

  Case RightPageCtrl.ActivePageIndex of
  0: ClientPageCtrl.ActivePageIndex :=0;
  end;// end of case
  
end;

procedure TMainForm.ClientPageCtrlChange(Sender: TObject);
begin
  //(TabSheetX.Components[0] as TListView).color:= clred;
  if ClientPageCtrl.ActivePageIndex <>0 then
  StatusBar.Panels[2].Text:='工作组:' pTabData(ClientPageCtrl.ActivePage.Tag).MyGroup 
           ' 主机和文件夹:' pTabData(ClientPageCtrl.ActivePage.Tag).MyDir;
end;

procedure TMainForm.N_OpenClick(Sender: TObject);
begin

  MyListViewClick(CurListView);
  
end;

procedure CopyToClipBoard(FileName:string);
var   DataHandle: THandle;
      DataPointer: PDROPFILES;
begin
  DataHandle := GlobalAlloc(GMEM_DDESHARE or GMEM_MOVEABLE,SizeOf(DROPFILES) 2 Length(FileName));
  DataPointer := PDROPFILES(GlobalLock(DataHandle));
  FillChar(DataPointer^,SizeOf(DROPFILES) 2 Length(FileName),0);

  DataPointer.pFiles:=SizeOf(DROPFILES);
  DataPointer.pt:=Point(0,0);
  DataPointer.fNC:=False;
  DataPointer.fWide:=False;
  Move(FileName[1],Pointer(Integer(DataPointer) SizeOf(DROPFILES))^,Length(FileName));
  GlobalUnlock(DataHandle);
  OpenClipboard(MainForm.Handle);
  EmptyClipboard;
  SetClipboardData(CF_HDROP, DataHandle);
  CloseClipboard;
end;

procedure TMainForm.N_CopyClick(Sender: TObject);
var
  FileName:string;
  i:integer;
begin

  FileName:='';
  for i:=1 to CurListView.Items.Count do
  if CurListView.Items[i-1].Selected
  then FileName:=FileName CurDirName CurListView.Items[i-1].Caption #0;
  CopyToClipBoard(FileName);

end;

procedure TMainForm.ListViewPopupMenuPopup(Sender: TObject);
var i:integer;
begin

  N_Open.Enabled := false;
  N_Copy.Enabled := false;
  N_Size.Enabled := false;
  N_OpenWithNotpad.Enabled :=false;
  N_Property.Enabled := false;
  N_NewWin.Enabled := false;
  N_Refresh.Enabled := false;
  N_Favorite.Enabled := false;
  N_CopyTo.Enabled := false;

  CurDirName:= pTabData(ClientPageCtrl.ActivePage.Tag).MyDir '\';
  CurGroupName :=pTabData(ClientPageCtrl.ActivePage.Tag).MyGroup;
  CurRlistItem :=pTabData(ClientPageCtrl.ActivePage.Tag).MyRListItem;

  if ClientPageCtrl.ActivePageIndex=0 then CurListView:=BrowseListView
  else CurListView:=(ClientPageCtrl.ActivePage.Components[0] as TListView);

  if CurListView.SelCount >0 then
  begin
    N_Open.Enabled := true;
    N_Copy.Enabled := true;
    N_Size.Enabled := true;
    N_CopyTo.Enabled := true;
    if (CurListView.SelCount=1)then
    begin
      N_Property.Enabled := true;
      if(CurListView.Selected.ImageIndex=1)then N_OpenWithNotpad.Enabled := true;
    end;
  end;
  if CurRListItem<>nil then
  begin
    N_NewWin.Enabled := true;
    N_Refresh.Enabled := true;
    N_Favorite.Enabled := true;
  end;
  
  for i:=1 to CurListView.Items.Count do
  if (CurListView.Items[i-1].Selected)and(CurListView.Items[i-1].ImageIndex=0)
  then  N_CopyTo.Enabled := false;

  
end;

//-------------------------------------------------------------------------
function GetDirectorySize(Path: String): Integer; //eg. Path = 'c:\temp\'
var
  SR: TSearchRec;
begin
  Result := 0;
  if path[length(path)]<>'\' then path:=path '\';
  if FindFirst(Path   '*.*', faAnyFile, SR) = 0 then
  begin
    if (sr.Name <> '.') and (sr.Name <> '..') and (sr.Attr = faDirectory) then
      Result := Result   GetDirectorySize(Path Sr.Name '\')
    else
      Result := Result   Sr.Size;
    while FindNext(sr) = 0 do
      if (sr.Name <> '.') and (sr.Name <> '..') and (sr.Attr = faDirectory) then
        Result := Result   GetdirectorySize(Path Sr.Name '\')
      else
        Result := Result   Sr.Size;
    FindClose(sr);
  end;
end;
//-------------------------------------------------------------------------

procedure TMainForm.N_SizeClick(Sender: TObject);
var fulls,msg:string; i,size,nFile,nFolder:integer;
begin

  size:=0;
  nFile:=0;
  nFolder:=0;
  //DirName:=pTabData(ClientPageCtrl.ActivePage.Tag).MyDir '\';
  for i:=1 to CurListView.Items.Count do
  begin
    if CurListView.Items[i-1].Selected
    then
    begin
      fulls:=CurDirName CurListView.Items[i-1].Caption;
      if CurListView.Items[i-1].ImageIndex<>0 then
      begin
        size:=size  GetFileSize(fulls);
        inc(nFile);
      end
      else
      begin
        size:=size GetDirectorySize(fulls);
        inc(nFolder);
      end;
      caption:=fulls;
    end;
  end;

  if nFolder=0 then msg := inttostr(nFile) ' 个文件'
  else if nFile=0 then msg:= inttostr(nFolder) ' 个文件夹'
  else  msg:= inttostr(nFile) ' 个文件,' inttostr(nFolder) ' 个文件夹';

  //ShowMessage(msg ' 共' FormatFloat('#,###" KB"',  size/ 1024) '(' inttostr(size) '字节)');
  Application.MessageBox(
        pchar(msg ' 共' FormatFloat('#,###" KB"',  size/ 1024) '(' inttostr(size) '字节)'),
        'File Size',
        MB_OK);

end;

procedure TMainForm.N_OpenWithNotpadClick(Sender: TObject);
var command:string;
    FileName:string;
begin

  //DirName:=pTabData(ClientPageCtrl.ActivePage.Tag).MyDir '\';
  FileName:=CurListView.Selected.Caption;
  command:= 'NotePad.exe ' CurDirName FileName;
  winexec(pchar(command),sw_normal);
  
end;

procedure TMainForm.N_NewWinClick(Sender: TObject);
var  Exe: TExecuteThread;
begin

 Exe:=TExecuteThread.Create(true);
 Exe.exeFile := CurDirName '\';
 Exe.exeDir := extractfilepath(Exe.exeFile);
 //caption:=exe.exeFile;
 Exe.FreeOnTerminate := true;
 Exe.Resume;
 
end;

procedure TMainForm.N_FavoriteClick(Sender: TObject);
var TemNode:TTreeNode;
    //ListItem:TListItem;
begin

  //caption:=dirname;
  New(MyItemPtr);
  MyItemPtr^.group := CurGroupName;
  MyItemPtr^.dirName := CurDirName;

  {ListItem:=ListView7.Items.Insert(0);
  listitem.Caption := CurDirName;
  listitem.SubItems.Text := CurGroupName;}

  temNode:=FavoTree.items.AddChild(FavoTree.Items[0],CurDirName);
  temNode.Data := MyItemPtr;
  FavoTree.Items[0].Expand(false);

  //assignfile(f,'Favorite.txt');
  assignfile(f,AppDir '\Favorite.txt');
  if not fileexists(AppDir '\Favorite.txt')then rewrite(f)
  else Append(f);
  writeln(f,trimright(CurGroupName));
  Writeln(f,CurDirName);
  //Flush(f);
  CloseFile(f);

end;

procedure TMainForm.SearchTreeClick(Sender: TObject);
begin
  LanTreeClick(SearchTree);
end;

procedure TMainForm.FavoTreeClick(Sender: TObject);
begin
  LanTreeClick(FavoTree);
end;

//------------------------------------------
function SHFindComputer(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;
 stdcall; external 'Shell32.dll' index 91;
 //----------------------------------------------
procedure TMainForm.BtnFindComputerClick(Sender: TObject);
var pidlRoot: PItemIDList;
    pidlSavedSearch: PItemIDList;
begin
  pidlRoot:=nil;  //just remove warning;
  pidlSavedSearch:=nil; //just remove warning;
  if not SHFindComputer(pidlRoot,pidlSavedSearch) then showmessage('error occured!');
end;

procedure TMainForm.BtnDOSClick(Sender: TObject);
begin

  if GetVersion<=4 then WinExec('Command.com',SW_SHOW)
  else WinExec('Cmd.exe',SW_SHOW)
  
end;

procedure TMainForm.BtnConfigorClick(Sender: TObject);
begin
  ConfigorForm.Show;
end;

procedure TMainForm.N_RefreshClick(Sender: TObject);
var DirSearcher:TSearchDirThread;
begin

  CurListView.Items.Clear;
  DirSearcher:=TSearchDirThread.create(true);
  DirSearcher.mydir := CurDirName;
  DirSearcher.mygroup := CurGroupName;
  DirSearcher.myList := CurListView;
  DirSearcher.Rlist :=FolderListView;
  DirSearcher.RListItem := pTabData(ClientPageCtrl.ActivePage.Tag).MyRListItem;
  //DirSearcher.myTree := Treeview1;
  DirSearcher.RListItem.ImageIndex := 6;
  DirSearcher.ClickType := InListView;
  DirSearcher.FreeOnTerminate := true;
  DirSearcher.Resume;
  
end;

procedure TMainForm.N_CopyToClick(Sender: TObject);
var i,j:integer;
    b:boolean;
    tems:string;
    TemListItem:TListItem;
begin

  with CopyToForm do
  begin
    for j:=1 to CopyListview.Items.Count do
    begin
      if CopyListview.Items[j-1].ImageIndex = 24 then CopyListview.Items[j-1].Delete;
    end;

    Show;
    caption:='拷贝文件';
    Label2.Caption:=CurDirName;
    //listview1.Items.Clear;
    //caption:=inttostr(CurListView.SelCount);
    for i:=1 to CurListView.Items.Count  do
    begin
    
      if CurListView.Items[i-1].Selected
        then
        begin
          tems:= CurDirName CurListView.Items[i-1].Caption;
          b:=false;
          for j:=1 to CopyListview.Items.Count do
          begin
            if tems = CopyListview.Items[j-1].Caption then b:=true;
            //if listview1.Items[j-1].ImageIndex = 24 then listview1.Items[j-1].Delete;
          end;
          if not b then
          begin
             temListItem:=CopyListview.Items.Add;
             temListItem.ImageIndex := 22;
             temListItem.Caption := tems;
          end;

        end;
    end;
    Combobox1.text:=ExtractFilepath(Combobox1.text);
    BtnCancel.Caption := '取消';
    //speedbutton3.Enabled := true;
    ComboBox1.Items.Add(combobox1.text);
    Label4.Caption := '共' inttostr(CopyListView.Items.Count) '个文件';

  end; //end of with

end;

procedure TMainForm.BtnRefreshTreeClick(Sender: TObject);
var GetDomainThread:TGetDomainThread;
begin

  BtnRefreshTree.Enabled:=false;
  GroupNum:=0;
  FinishNum:=0;
  CanOpen:=false;
  OldFileCount:=0;
  GetDomainThread:=TGetDomainThread.Create(true);
  GetDomainThread.LanTree := SearchTree;
  GetDomainThread.Resume;

end;

procedure TMainForm.N_SaveAllClick(Sender: TObject);
begin

  case BottomPageCtrl.ActivePageIndex of
  0: SaveDlg.FileName := 'LAN_log_All(' DateToStr(now) ')';
  1: SaveDlg.FileName := 'LAN_log_Search(' DateToStr(now) ')';
  2: SaveDlg.FileName := 'LAN_log_Mp3(' DateToStr(now) ')';
  3: SaveDlg.FileName := 'LAN_log_Movie(' DateToStr(now) ')';
  end;

  if SaveDlg.execute then if SaveDlg.filename<>'' then
  case BottomPageCtrl.ActivePageIndex of
  0: StrListAll.SaveToFile(SaveDlg.FileName);
  1: StrListSearch.SaveToFile(SaveDlg.FileName);
  2: StrListMp3.SaveToFile(SaveDlg.FileName);
  3: StrListMovie.SaveToFile(SaveDlg.FileName);
  end; //end of case

end;

procedure TMainForm.Menu_TreeClick(Sender: TObject);
begin

  {LeftPanel.AutoSize := false;
  LeftPanel.Width := 200;}
  LeftDockPanel.Show;
  if LeftPanel.VisibleDockClientCount>0 then LeftPanel.Show;
  Menu_Tree.Checked := true;
  MyEndDock;
  {LeftPanel.AutoSize := true;}

end;

procedure TMainForm.Menu_FolderClick(Sender: TObject);
begin
  {RightPanel.AutoSize := false;
  RightPanel.Width := 160;}
  RightDockPanel.Show;
  if RightPanel.VisibleDockClientCount>0 then
  begin
    RightPanel.Show;
    Splitter3.Align := alLeft;
    Splitter3.Align := alRight;
    //MyEndDock;
  end;
  Menu_Folder.Checked := true;
  {RightPanel.AutoSize := true;}
end;

procedure TMainForm.Menu_ResultClick(Sender: TObject);
begin
  {BottomPanel.AutoSize := false;
  BottomPanel.Height := 100;}
  {BottomPanel.Align := altop;
  BottomPanel.Align := alBottom;}
  BottomDockPanel.Show;
  if BottomPanel.VisibleDockClientCount>0 then BottomPanel.Show;
  Menu_Result.Checked := true;
  MyEndDock;
  {BottomPanel.AutoSize := true;}
end;

procedure TMainForm.BtnAutoSearchClick(Sender: TObject);
begin

   MainSearch:=TMainThread.create(true);
   //MainSearch.OnTerminate := OnMainTerminate;
   MainSearch.FreeOnTerminate := true;
   MainSearch.Resume;
   BtnPause.Enabled := true;
   BtnStop.Enabled := true;
   BtnAutoSearch.Enabled := false;

end;

procedure TMainForm.LanExplorer1Click(Sender: TObject);
begin
  AboutForm.Show;
end;

procedure TMainForm.BtnPauseClick(Sender: TObject);
begin
  if not BtnPause.Down then
  begin
    MainSearch.Suspend;
    BtnStop.Enabled := true;
    //BtnPause.Down := true;
  end
  else
  begin
    MainSearch.Resume;
    BtnStop.Enabled := false;
    //BtnPause.Down := false;
  end;
end;

procedure TMainForm.BtnStopClick(Sender: TObject);
begin

   MainSearch.Suspend;
   MainSearch.Terminate;
   //MainSearch.WaitFor;
   MainSearch.free;
   BtnStop.Enabled := false;
   BtnPause.Enabled := false;
   BtnAutoSearch.Enabled := true;

end;

procedure TMainForm.N_DeleteFavoClick(Sender: TObject);
begin
  if FavoTree.Selected <> nil then TemTreeNode.Delete;
end;

procedure TMainForm.FavoTreePopupMenuPopup(Sender: TObject);
begin
  N_DeleteFavo.Enabled := false;
  if FavoTree.Selected <> nil then
  begin
    N_DeleteFavo.Enabled := true;
    N_DeleteFavo.Caption := '删除 '  FavoTree.Selected.Text;
    TemTreeNode:=FavoTree.Selected;
  end;
end;

procedure TMainForm.IconCheckBoxClick(Sender: TObject);
begin
  bSysIcon:=IconCheckBox.Checked;
end;

procedure TMainForm.AllListBoxDblClick(Sender: TObject);
var fn,dn:string; Exe: TExecuteThread;
begin

  //caption:=inttostr(AllListBox.SelCount);
  if AllListBox.SelCount >0 then
  begin
    fn:= AllListBox.Items[AllListbox.ItemIndex];
    dn:=extractfilepath(fn);
    Exe:=TExecuteThread.Create(true);
    Exe.exeFile := fn;
    Exe.exeDir := dn;
    Exe.FreeOnTerminate := true;
    Exe.Resume;
  end;

end;

procedure TMainForm.MyBottomListViewClick(ListView:TListView);
var  Exe: TExecuteThread;
begin

  if ListView.SelCount <>0 then
  begin
   Exe:=TExecuteThread.Create(true);
   Exe.exeFile := trim(ListView.Selected.SubItems[0]) '\' ListView.Selected.Caption;
   Exe.exeDir := extractfilepath(Exe.exeFile);
   //caption:=exe.exeFile;
   with ListView.Selected do
   begin
   if ImageIndex=1 then ImageIndex := 17 else
   if ImageIndex=17 then ImageIndex := 1 else
   if ImageIndex=0 then ImageIndex:=10;
   end;
   Exe.FreeOnTerminate := true;
   Exe.Resume;
  end;

end;

procedure TMainForm.FindListViewDblClick(Sender: TObject);
begin
  MyBottomListViewClick(FindListView);
end;

procedure TMainForm.Mp3ListViewDblClick(Sender: TObject);
begin
  MyBottomListViewClick(Mp3ListView);
end;

procedure TMainForm.MovieListViewDblClick(Sender: TObject);
begin
  MyBottomListViewClick(MovieListView);
end;

procedure TMainForm.BottomPopupMenuPopup(Sender: TObject);
var i:integer;
begin

  N_BottomCopyTo.Enabled := true;
  N_SaveAll.Enabled := true;
  N_BottomOpen.Enabled := false;
  N_BottomCopy.Enabled := true;
  N_BottomFileSize.Enabled := true;
  case BottomPageCtrl.ActivePageIndex of
  0: begin
       CurBottomListView:=nil;
       if AllListBox.Items.Count=0 then
       begin
         N_SaveAll.Enabled := false;
       end;

       if AllListBox.SelCount <=0 then
       begin
         N_BottomCopyTo.Enabled := false;
         N_BottomCopy.Enabled := false;
         N_BottomFileSize.Enabled := false;
       end
       else
       begin
         if AllListBox.SelCount=1 then N_BottomOpen.Enabled := true;
         
         for i:=1 to AllListBox.Items.Count do
         begin
           if AllListBox.Selected[i-1] then
           if AllListBox.Items[i-1][length(AllListBox.Items[i-1])]='\'
           then N_BottomCopyTo.Enabled := false;
         end;
         
       end;

     end;
  1: CurBottomListView:= FindListView;
  2: CurBottomListView:= Mp3ListView;
  3: CurBottomListView:= MovieListView;
  end; //end of case
  
  if CurBottomListView<>nil then
  begin
    if CurBottomListView.Items.Count=0  then
    begin
      N_SaveAll.Enabled := false;
    end;

    if CurBottomListView.SelCount<=0 then
    begin
      N_BottomCopyTo.Enabled := false;
      N_BottomCopy.Enabled := false;
      N_BottomFileSize.Enabled := false;
    end
    else
    begin
      if CurBottomListView.SelCount=1 then N_BottomOpen.Enabled := true;
      
      for i:=1 to CurBottomListView.Items.Count do
      if (CurBottomListView.Items[i-1].Selected)and(CurBottomListView.Items[i-1].ImageIndex=0)
      then  N_BottomCopyTo.Enabled := false;
    end;
  end;
  
end;


procedure TMainForm.N_BottomOpenClick(Sender: TObject);
begin
  case BottomPageCtrl.ActivePageIndex of
  0: AllListBoxDblClick(Self);
  1: FindListViewDblClick(Self);
  2: Mp3ListViewDblClick(Self);
  3: MovieListViewDblClick(Self);
  end; //end of case
end;

procedure TMainForm.N_BottomCopyClick(Sender: TObject);
var
  FileName:string;
  i:integer;
begin
  
  if CurBottomListView=nil
  then
  begin
    FileName:='';
    for i:=1 to AllListBox.Items.Count do
    if AllListBox.Selected[i-1]
    then FileName:=FileName AllListBox.Items[i-1] #0;
    CopyToClipBoard(FileName);
  end
  else
  begin
    FileName:='';
    for i:=1 to CurBottomListView.Items.Count do
    if CurBottomListView.Items[i-1].Selected
    then FileName:=CurBottomListView.Items[i-1].SubItems[0] '\' CurBottomListView.Items[i-1].Caption;
    CopyToClipBoard(FileName);
  end;
  
end;

procedure TMainForm.N_BottomFileSizeClick(Sender: TObject);
var fulls:string; i,size,SelCount:integer;
begin
  size:=0;

  if CurBottomListView<>nil then
  begin
    SelCount:= CurBottomListView.selcount;
    for i:=1 to  CurBottomListView.Items.Count do
    begin
      if CurBottomListView.Items[i-1].Selected
      then
      begin
        fulls:=CurBottomListView.Items[i-1].SubItems[0] '\' CurBottomListView.Items[i-1].Caption;
        if  CurBottomListView.Items[i-1].ImageIndex=1
        then size:=size  GetFileSize(fulls)
        else size:=size  GetDirectorySize(fulls)
      end;
    end;
  end
  else   // in listbox
  begin
    SelCount:=AllListBox.SelCount;
    for i:=1 to  AllListBox.Items.Count do
    begin
      if AllListBox.Selected[i-1]
      then
      begin
        fulls:=AllListBox.Items[i-1];
        if fulls[length(fulls)]<>'\' then size:=size  GetFileSize(fulls)
        else size:=size  GetDirectorySize(fulls)
      end;
    end;
  end;
  
  ShowMessage(inttostr(SelCount) ' 个文件(夹)' FormatFloat('#,###" KB"',  size/ 1024)
              '(' inttostr(size) '字节)');
end;

procedure TMainForm.N_BottomCopyToClick(Sender: TObject);
var i,j:integer;
    b:boolean;
    tems:string;
    TemListItem:TListItem;
begin

  with CopyToForm do
  begin

    for j:=1 to CopyListview.Items.Count do
    begin
      if CopyListview.Items[j-1].ImageIndex = 24 then CopyListview.Items[j-1].Delete;
    end;

    Show;
    caption:='拷贝文件';
    Label2.Caption:='Any Where';
    //listview1.Items.Clear;
    //caption:=inttostr(CurListView.SelCount);
    if CurBottomListView<>nil then
    for i:=1 to CurBottomListView.Items.Count  do
    begin
      if CurBottomListView.Items[i-1].Selected
        then
        begin
          tems:= CurBottomListView.Items[i-1].SubItems[0] '\' CurBottomListView.Items[i-1].Caption;
          b:=false;
          for j:=1 to CopyListview.Items.Count do
          begin
            if tems = CopyListview.Items[j-1].Caption then b:=true;
            //if listview1.Items[j-1].ImageIndex = 24 then listview1.Items[j-1].Delete;
          end;
          if not b then
          begin
             temListItem:=CopyListview.Items.Add;
             temListItem.ImageIndex := 22;
             temListItem.Caption := tems;
          end;
        end;
    end
    else
    for i:=1 to  AllListBox.Items.Count do
    begin
      if AllListBox.Selected[i-1]
      then
      begin
        tems:=AllListBox.Items[i-1];
        b:=false;
        for j:=1 to CopyListview.Items.Count do
        begin
          if tems=CopyListview.Items[j-1].Caption then b:=true;
        end;
        if not b then
        begin
          temListItem:=CopyListview.Items.Add;
          temListItem.ImageIndex := 22;
          temListItem.Caption := tems;
        end;
      end;
    end;

    Combobox1.text:=ExtractFilepath(Combobox1.text);
    BtnCancel.Caption := '取消';
    //speedbutton3.Enabled := true;
    ComboBox1.Items.Add(combobox1.text);
    Label4.Caption := '共' inttostr(CopyListView.Items.Count) '个文件';

  end; //end of with

end;

procedure TMainForm.StatusBarMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
 ReleaseCapture;
 SendMessage(handle,wm_SysCommand,$F012,0);
end;

procedure TMainForm.FormResize(Sender: TObject);
begin

 with Statusbar do
 Panels[2].Width := Width- Panels[0].Width
                         - Panels[1].Width
                         - Panels[3].Width;
                         //- Panels[4].Width;

end;

procedure GetFileProperty(f:string);
var SEI:PSHELLEXECUTEINFOA;
begin
   getmem(sei,sizeof(sei^));
   With SEI^ do
   begin
     cbSize:= sizeof(SEI^);
     fMask:= SEE_MASK_NOCLOSEPROCESS Or SEE_MASK_INVOKEIDLIST Or SEE_MASK_FLAG_NO_UI;
     wnd:=MainForm.handle;
     lpVerb:= 'properties';
     lpFile:=pchar(f);  //你自己的文件名
     lpParameters:=nil;
     lpDirectory:=nil;
     nShow:=0;
     hInstApp:=hInstance;
     lpIDList:=nil;
   End;
 ShellExecuteEX(SEI);
 freemem(sei);
end;

procedure TMainForm.N_PropertyClick(Sender: TObject);
begin
  GetFileProperty(CurDirName CurListView.Selected.Caption);
end;

end.

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复