📄 updownfrom.pas
字号:
Result := 1;
Exit;
end;
if (Item1.ImageIndex > 4) and (Item2.ImageIndex > 4)
and (Item1.ImageIndex < 32) and (Item2.ImageIndex < 32) then begin
if ToFileSize(Item1.SubItems.Strings[0]) > ToFileSize(Item2.SubItems.Strings[0]) then
Result := 1
else Result := -1;
Exit;
end;
if (Item1.ImageIndex > 32) and (Item2.ImageIndex > 32) then begin
if ToFileSize(Item1.SubItems.Strings[0]) > ToFileSize(Item2.SubItems.Strings[0]) then
Result := 1
else Result := -1;
Exit;
end;
if (Item1.ImageIndex = 4) and (Item2.ImageIndex > 4) then begin
Result := -1;
Exit;
end;
if (Item1.ImageIndex = 32) and (Item2.ImageIndex > 32) then begin
Result := -1;
Exit;
end;
end;
end;
2:
begin
if UpDown[2] = True then begin
if (Item1.ImageIndex = 4) and (Item2.ImageIndex = 4) then begin
Result := CompareText(Item1.SubItems[1], Item2.SubItems[1]);
Exit;
end;
if (Item1.ImageIndex = 32) and (Item2.ImageIndex = 32) then begin
Result := CompareText(Item1.SubItems[1], Item2.SubItems[1]);
Exit;
end;
if (Item1.ImageIndex > 4) and (Item2.ImageIndex > 4)
and (Item1.ImageIndex < 28) and (Item2.ImageIndex < 28) then begin
Result := CompareText(Item1.SubItems[1], Item2.SubItems[1]);
Exit;
end;
if (Item1.ImageIndex > 32) and (Item2.ImageIndex > 32) then begin
Result := CompareText(Item1.SubItems[1], Item2.SubItems[1]);
Exit;
end;
if (Item1.ImageIndex = 4) and (Item2.ImageIndex > 4) then begin
Result := -1;
Exit;
end;
if (Item1.ImageIndex = 32) and (Item2.ImageIndex > 32) then begin
Result := -1;
Exit;
end;
end else begin
if (Item1.ImageIndex = 4) and (Item2.ImageIndex = 4) then begin
Result := -CompareText(Item1.SubItems[1], Item2.SubItems[1]);
Exit;
end;
if (Item1.ImageIndex = 32) and (Item2.ImageIndex = 32) then begin
Result := -CompareText(Item1.SubItems[1], Item2.SubItems[1]);
Exit;
end;
if (Item1.ImageIndex > 4) and (Item2.ImageIndex > 4)
and (Item1.ImageIndex < 28) and (Item2.ImageIndex < 28) then begin
Result := -CompareText(Item1.SubItems[1], Item2.SubItems[1]);
Exit;
end;
if (Item1.ImageIndex > 32) and (Item2.ImageIndex > 32) then begin
Result := -CompareText(Item1.SubItems[1], Item2.SubItems[1]);
Exit;
end;
if (Item1.ImageIndex = 4) and (Item2.ImageIndex > 4) then begin
Result := -1;
Exit;
end;
if (Item1.ImageIndex = 32) and (Item2.ImageIndex > 32) then begin
Result := -1;
Exit;
end;
end;
end;
end;
except
end;
end;
procedure TUpDownFileForm.TreeView1Change(Sender: TObject;
Node: TTreeNode);
function getfilesize(str: string): string;
var len: integer;
begin
len := pos('|', str); //文件夹目录主要操作
result := copy(str, 1, len - 1);
end;
var
Tempnode: TTreenode;
path: string;
Tmpmemo: TStringlist;
i,j: integer;
tmplinestr, symbolstr, tmptimestr: string;
TempS: string;
TMP: TTreeNode;
ListFileType: TViewStyle;
begin
if (Treeview1.Selected.ImageIndex = 0) then
begin
GetComputer; //获取本地磁盘
ViKing.UpDir := ''; {清空服务器端路径}
Exit;
end;
//选择我的电脑驱动器和文件夹
if (Treeview1.Selected.ImageIndex > 0) and (Treeview1.Selected.ImageIndex < 7) then begin
Animate1.Active := True;
Animate1.Visible := True;
try
Tmpmemo := TStringlist.Create; {我的电脑的操作}
Tmpmemo.clear;
Tempnode := node;
Treeview1.items.BeginUpdate; {禁止Treeview1刷新}
Treeview1.Selected.DeleteChildren; {删除选中的所有子节}
Treeview1.items.EndUpdate; {允许Treeview1刷新}
Enabled := False;
while tempnode.Parent <> nil do //如果父节点不为空
begin
path := tempnode.text + '\' + path;
Tempnode := tempnode.Parent;
end;
ViKing.UpDir := Path; {*****我的电脑目录路径*****}
Tmpmemo.Text := FindFile(path); {查找路径下的文件夹和文件}
listview1.Items.BeginUpdate; {禁止listview1刷新}
Treeview1.items.BeginUpdate; {禁止Treeview1刷新}
ListView1.Items.Clear; {清空ListView1}
if Tmpmemo.Text = '' then begin
listview1.Items.EndUpdate; {允许listview1刷新}
Treeview1.Items.EndUpdate; {允许Treeview1刷新}
Enabled := True;
Animate1.Active := False;
Animate1.Visible := False;
Exit;
end;
except
Enabled := True;
Exit;
end;
ListFileType := ListView1.ViewStyle;
ListView1.ViewStyle := vsList;
Application.ProcessMessages;
try
for i := 0 to Tmpmemo.Count - 1 do
begin
tmplinestr := Tmpmemo.Strings[i];
symbolstr := copy(tmplinestr, 1, 1);
tmptimestr := copy(tmplinestr, 2, 16);
Delete(tmplinestr, 1, 17);
if symbolstr = '*' then
begin
TMP := Treeview1.items.AddChild(Treeview1.Selected, Tmplinestr);
TMP.ImageIndex := 5;
TMP.SelectedIndex := 6;
TMP := Treeview1.items.AddChild(TMP, '.');
TMP.ImageIndex := -1;
TMP.SelectedIndex := -1;
with listview1.Items.Add do
begin
Caption := tmplinestr;
subitems.text := ' ';
Listview1.Items.Item[i].SubItems.Add(Tmptimestr);
ImageIndex := 4;
end;
end;
if symbolstr = '\' then
begin
with listview1.Items.Add do
begin
Caption := copy(tmplinestr, length(getfilesize(tmplinestr)) + 2, length(tmplinestr));
Subitems.text := getfilesize(tmplinestr);
Listview1.Items.Item[i].SubItems.Add(Tmptimestr);
ImageIndex := ViKing.PcfilePic(lowercase(ExtractFileExt(Caption))); {找到文件类型图标}
end;
end;
end;
ListView1.CustomSort(@CustomSortProc, 4);
finally
ListView1.ViewStyle := ListFileType;
listview1.Items.EndUpdate;
Treeview1.Items.EndUpdate;
end;
Animate1.Active := False;
Animate1.Visible := False;
Enabled := True;
Tmpmemo.Free;
Exit;
end;
try
Animate1.Active := False;
Animate1.Visible := False;
except
end;
end;
procedure TUpDownFileForm.ListView1DblClick(Sender: TObject);
var
I, II: Integer;
Strtmp: string;
li: TListItem;
begin
try
li := ListView1.Selected; {我的电脑文件}
except
end;
try
TreeView1.Selected.Expand(False); {展开TreeView1选中的项目}
Strtmp := TListView(sender).Selected.Caption;
II := 0;
for I := TreeView1.Selected.Index to TreeView1.Items.Count - 1 do
begin
if TreeView1.Selected.Item[II].Text = Strtmp then
begin
TreeView1.Selected.Item[II].Selected := True;
Exit;
end;
inc(II);
end;
except
end;
end;
procedure TUpDownFileForm.TreeView1Expanding(Sender: TObject;
Node: TTreeNode; var AllowExpansion: Boolean);
begin
AllowExpansion := (Node.getFirstChild.ImageIndex <> -1);
if not (AllowExpansion) then
begin
TreeView1.Selected := Node;
end;
end;
procedure TUpDownFileForm.ControlBar2Resize(Sender: TObject);
begin
try
Panel19.Width := ControlBar2.Width;
except
end;
end;
//确定
procedure TUpDownFileForm.spSkinButton1Click(Sender: TObject);
var
li: TListItem;
begin
li := ListView1.Selected;
if li = nil then Exit;
if li.ImageIndex = 4 then
ViKing.UpFileFolder:= ViKing.UpDir+li.Caption
else
ViKing.UpFileNames:= ViKing.UpDir+li.Caption;
close;
end;
//取消
procedure TUpDownFileForm.spSkinButton2Click(Sender: TObject);
begin
close;
end;
procedure TUpDownFileForm.FormShow(Sender: TObject);
begin
ViKing.UpFileFolder:='';
ViKing.UpFileNames:='';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -