⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 该程序用D5编译
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  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;
  f             : TextFile;
  MyItemPtr     : PMyTreeItem;
begin

  //caption:=dirname;
  if(CurDirName[length(CurDirName)]='\')then delete(CurDirName,length(CurDirName),1);
  New(MyItemPtr);
  MyItemPtr^.group := CurGroupName;
  MyItemPtr^.dirName := CurDirName;

  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;

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

  DisposeListViewData(CurListView);
  CurListView.Items.Clear;
  DirSearcher:=TSearchDirThread.create(true);
  DirSearcher.mydir := CurDirName;
  DirSearcher.mygroup := CurGroupName;
  DirSearcher.myList := CurListView;
  //DirSearcher.Rlist :=ShareListView;
  DirSearcher.RListItem := pTabData(ClientPageCtrl.ActivePage.Tag).MyRListItem;
  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:=CopyListview.Items.Count downto 1 do    //should use downto
    begin
      if CopyListview.Items[j-1].ImageIndex = 24 then CopyListview.Items[j-1].Delete;
    end;

    Show;
    if WindowState = wsMinimized then ShowWindow(Handle, SW_RESTORE);

    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;
             temListItem.SubItems.Add('尚未开始');
          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.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)and(SaveDlg.FileName<>'') then
  begin
    NewStyleControls := False;  //why?
    case BottomPageCtrl.ActivePageIndex of
    0: AllListBox.Items.SaveToFile(SaveDlg.FileName);
    1: StrListSearch.SaveToFile(SaveDlg.FileName);
    2: StrListMp3.SaveToFile(SaveDlg.FileName);
    3: StrListMovie.SaveToFile(SaveDlg.FileName);
    end; //end of case
    NewStyleControls := True;
  end;

end;

procedure TMainForm.Menu_TreeClick(Sender: TObject);
begin
  Menu_Tree.Checked := not  Menu_Tree.Checked;
  LeftPanel.Visible := Menu_Tree.Checked;
  Splitter2.Visible := Menu_Tree.Checked;
  Splitter2.Align := alRight;
  Splitter2.Align := alLeft;
end;

procedure TMainForm.Menu_ResultClick(Sender: TObject);
begin

  Menu_Result.Checked := not Menu_Result.Checked;
  BottomPanel.Visible := Menu_Result.Checked;
  Splitter1.Visible := Menu_Result.Checked;
  Splitter1.Align := altop;
  Splitter1.Align := albottom;

end;

procedure TMainForm.Menu_AboutClick(Sender: TObject);
begin
  AboutForm.Show;
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;
  N_BottomOpenDir.Enabled := false;
  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
         begin
           N_BottomOpen.Enabled := true;
           N_BottomOpenDir.Enabled := true;
         end;
         
         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
      begin
        N_BottomOpen.Enabled := true;
        N_BottomOpenDir.Enabled := true;
      end;
      
      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, Handle);
  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, Handle);
  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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -