📄 main.pas
字号:
procedure TMainForm.AddCap(group:string;dir:string);
begin
if (group='')and(dir='') then
begin
pnlHeader.Caption := '';
exit;
end;
if group[length(group)]=#0 then delete(group,length(group),1);
pnlHeader.Caption := ' 工作组:'+GroupFunc(group)+' 主机和文件夹:'+dir;
StatusBar.Panels[2].Text := pnlHeader.Caption;
end;
procedure TExecuteThread.Execute;
begin
ExecuteFile(exefile,'',exedir,SW_SHOW);
end;
procedure TMainForm.PageControlWndProc1(var Message: TMessage); //Client
begin
FOriginalPageControlWndProc1(Message);
with Message do
if (Msg = TCM_ADJUSTRECT) and (Message.WParam = 0) then
begin
PRect(LParam)^.Top := PRect(LParam)^.Top-5;
PRect(LParam)^.Bottom := PRect(LParam)^.Bottom-2;
PRect(LParam)^.left := PRect(LParam)^.left;
PRect(LParam)^.Right := PRect(LParam)^.Right+1;
InflateRect(PRect(LParam)^, 5, 3);
end;
end;
procedure TMainForm.PageControlWndProc3(var Message: TMessage); //left
begin
FOriginalPageControlWndProc3(Message);
with Message do
if (Msg = TCM_ADJUSTRECT) and (Message.WParam = 0) then
begin
PRect(LParam)^.Top := PRect(LParam)^.Top;
PRect(LParam)^.Bottom := PRect(LParam)^.Bottom +3;
PRect(LParam)^.left := PRect(LParam)^.left-1;
PRect(LParam)^.Right := PRect(LParam)^.Right;
InflateRect(PRect(LParam)^, 5, 3);
end;
end;
procedure TMainForm.PageControlWndProc4(var Message: TMessage); //bottom
begin
FOriginalPageControlWndProc4(Message);
with Message do
if (Msg = TCM_ADJUSTRECT) and (Message.WParam = 0) then
begin
PRect(LParam)^.Top := PRect(LParam)^.Top-7;
PRect(LParam)^.left := PRect(LParam)^.left;
InflateRect(PRect(LParam)^, 5, 1);
end;
end;
procedure TMainForm.PageControlWndProc5(var Message: TMessage); //search
begin
FOriginalPageControlWndProc5(Message);
with Message do
if (Msg = TCM_ADJUSTRECT) and (Message.WParam = 0) then
begin
PRect(LParam)^.Top := PRect(LParam)^.Top-3;
PRect(LParam)^.Bottom := PRect(LParam)^.Bottom +2;
PRect(LParam)^.left := PRect(LParam)^.left;
InflateRect(PRect(LParam)^, 4, 1);
end;
end;
procedure TMainForm.CheckFile(FileName,MyDir,MyGroup:string;ImageIndex:integer);
var
listitem: TListitem;
begin
with ConfigForm do
begin
if CheckDest(FileName) then
begin
listitem:=FindListview.Items.Add;
if ImageIndex<>0 then listitem.ImageIndex:= GetImgIndex(FileName) else
listitem.ImageIndex := ImageIndex;
listitem.Caption := extractfilename(FileName);
listitem.SubItems.add(MyDir);
listitem.SubItems.add(MyGroup);
StrListSearch.Add(' 工作组:'+GroupFunc(MyGroup)+' 地址:'+MyDir+'\'+FileName);
end;
if CheckMP3(FileName) then
begin
listitem:=MP3Listview.Items.Add;
if ImageIndex<>0 then listitem.ImageIndex:= GetImgIndex(FileName) else
listitem.ImageIndex := ImageIndex;
listitem.Caption := extractfilename(FileName);
listitem.SubItems.add(MyDir);
listitem.SubItems.add(MyGroup);
StrListMp3.Add(' 工作组:'+GroupFunc(MyGroup)+' 地址:'+MyDir+'\'+FileName);
end;
if CheckMovie(FileName) then
begin
listitem:=MovieListview.Items.Add;
if ImageIndex<>0 then listitem.ImageIndex:= GetImgIndex(FileName) else
listitem.ImageIndex := ImageIndex;
listitem.Caption := extractfilename(FileName);
listitem.SubItems.add(MyDir);
listitem.SubItems.add(MyGroup);
StrListMovie.Add(' 工作组:'+GroupFunc(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.writeInteger('panel position','left_panel',LeftPanel.Width);
//ini.writeInteger('panel position','right_panel',RightPanel.Width);
ini.writeInteger('panel position','bottom_panel',BottomPanel.Height);
ini.writeString('Dock','RightDockPanel','alRight');
// nbtstat IP address
ini.writeString('NBT_IP','IP1','192.168.0.1');
ini.writeString('NBT_IP','IP2','192.168.0.255');
// TCP port scan address
ini.writeString('TCP_PORT_SCAN','IP1','192.168.0.1');
ini.writeString('TCP_PORT_SCAN','IP2','192.168.0.255');
// ping IP address
ini.writeString('PING','IP1','192.168.0.1');
ini.writeString('PING','IP2','192.168.0.255');
// Scan IP address
ini.writeString('SCAN','IP1','192.168.0.1');
ini.writeString('SCAN','IP2','192.168.0.255');
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;
LeftPanel.Width:=ini.ReadInteger('panel position','left_panel',LeftPanel.Width);
//RightPanel.Width:=ini.ReadInteger('panel position','right_panel',RightPanel.Width);
BottomPanel.Height:=ini.ReadInteger('panel position','bottom_panel',BottomPanel.Height);
//nbtstat IP address
Nbt_IP1 := ini.ReadString('NBT_IP', 'IP1', '192.168.0.1');
Nbt_IP2 := ini.ReadString('NBT_IP', 'IP2', '192.168.0.255');
//TCP port scan address
ScanPort_IP1 := ini.ReadString('TCP_PORT_SCAN','IP1','192.168.0.1');
ScanPort_IP2 := ini.ReadString('TCP_PORT_SCAN','IP2','192.168.0.255');
//ping IP address
Ping_IP1 := ini.ReadString('PING','IP1','192.168.0.1');
Ping_IP2 := ini.ReadString('PING','IP2','192.168.0.255');
//CheckIpForm.edtStart.Text
edtIP1.Text := ini.ReadString('SCAN', 'IP1', '192.168.0.1');
edtIP2.Text := ini.ReadString('SCAN', 'IP2', '192.168.0.255');
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);
ini.writeInteger('panel position','left_panel',LeftPanel.Width);
//ini.writeInteger('panel position','right_panel',RightPanel.Width);
ini.writeInteger('panel position','bottom_panel',BottomPanel.Height);
//nbtstat IP address
ini.WriteString('NBT_IP', 'IP1', ToolsForm.edtNbtIP1.Text);
ini.WriteString('NBT_IP', 'IP2', ToolsForm.edtNbtIP2.Text);
//TCP port scan address
ini.writeString('TCP_PORT_SCAN','IP1',ToolsForm.edtScanIP1.Text);
ini.writeString('TCP_PORT_SCAN','IP2',ToolsForm.edtScanIP2.Text);
//ping IP address
ini.writeString('PING','IP1',ToolsForm.edtPing1.Text);
ini.writeString('PING','IP2',ToolsForm.edtPing2.Text);
//Scan IP address
ini.writeString('SCAN','IP1',edtIP1.Text);
ini.writeString('SCAN','IP2',edtIP2.Text);
ini.Free;
end;
procedure TMainForm.OpenHistory;
var
RootNode, TemNode, GroupNode: TTreeNode;
s: string;
f: TextFile;
MyItemPtr : PMyTreeItem;
begin
RootNode:=HistoryTree.Items[0];
GroupNode := RootNode; ///
if fileexists('History.txt') then
begin
assignfile(f,'History.txt');
reset(f);
while not eof(f) do
begin
Application.ProcessMessages;
readln(f,s);
s := trim(s);
if s = '' then continue;
if s[1] <> '\' then //group
begin
GroupNode := HistoryTree.Items.AddChild(RootNode,s);
GroupNode.ImageIndex := 9;
GroupNode.SelectedIndex := 9;
end
else
begin
New(MyItemPtr);
MyItemPtr^.group := GroupNode.Text;
MyItemPtr^.dirName := s;
TemNode:=HistoryTree.Items.AddChild(GroupNode, s);
TemNode.Data := MyItemPtr;
TemNode.ImageIndex := 7;
TemNode.SelectedIndex := 7;//12;
GroupNode.Expand(false);
end;
end;
closefile(f);
RootNode.Expand(false);
end;
end;
procedure TMainForm.SaveHistory;
var
i, j : integer;
TempGroupNode : TTreeNode;
f : TextFile;
begin
if AppDir[1]<>'\' then //open on the LAN
begin
assignfile(f,AppDir+'\History.txt');
rewrite(f);
if HistoryTree.Items[0].HasChildren then
begin
//TempGroupNode:=nil; // just remove warning;
for i:=1 to HistoryTree.Items[0].count do
begin
TempGroupNode:= HistoryTree.Items[0].Item[i-1]; //groups
writeln(f,TempGroupNode.text);
for j := 1 to TempGroupNode.Count do writeln(f,TempGroupNode.Item[j-1].Text); //host
end;
//caption:=TempGroupNode.text; // just remove warning;
end;
closefile(f);
end;
end;
function CheckFavo(s:string):integer;
var
i, j: integer;
begin
j:=0;
for i:=1 to length(s) do if s[i]='\' then inc(j);
result := j;
end;
procedure TMainForm.OpenFavorite;
var
RootNode,TemNode : TTreeNode;
fg,fs : string;
f : TextFile;
MyItemPtr : PMyTreeItem;
begin
RootNode:=FavoTree.Items[0];
if fileexists('Favorite.txt') then
begin
assignfile(f,'Favorite.txt');
reset(f);
while not eof(f) do
begin
Application.ProcessMessages;
readln(f,fg);
New(MyItemPtr);
MyItemPtr^.group := trim(fg);
readln(f,fs);
MyItemPtr^.dirName := trim(fs);
if (trim(fg)='')or(trim(fs)='') then
begin
Dispose(MyItemPtr);
continue;
end;
TemNode:=FavoTree.Items.AddChild(RootNode,fs);
TemNode.Data := MyItemPtr;
case CheckFavo(fs) of
0:begin
TemNode.ImageIndex := 5;
TemNode.SelectedIndex := 5;//16;
end;
2:begin
TemNode.ImageIndex := 7;
TemNode.SelectedIndex := 7;//12;
end;
else TemNode.ImageIndex := 0;
end; //end of case;
end;
closefile(f);
try
FavoTree.Items[0].Expand(false);
except on ETreeViewError do FavoTree.Items.AddChildFirst(nil,'收藏');
end; //end of try
end;
end;
procedure TMainForm.SaveFavorite;
var
i : integer;
TempNode : TTreeNode;
f : TextFile;
begin
if AppDir[1]<>'\' then //open on the LAN
try
begin
assignfile(f,AppDir+'\Favorite.txt');
rewrite(f);
if FavoTree.Items[0].HasChildren then
begin
//tempNode:=nil; // just remove warning;
for i:=1 to FavoTree.Items[0].count do
begin
tempNode:= FavoTree.Items[0].Item[i-1];
if tempNode.data <> nil then
try
writeln(f,trimright(pMyTreeItem(tempNode.data)^.group));
writeln(f,tempNode.text);
except {do nothing} end;
end;
//caption:=tempNode.text; // just remove warning;
end;
closefile(f);
end
except {do nothing} end;
end;
{procedure TMainForm.BringFront;
begin
Application.BringToFront;
end;}
procedure TMainForm.MyListViewClick(Sender: TObject);
var
DirName,FileName,GroupName : string;
DirSearcher : TSearchDirThread;
Exe : TExecuteThread;
newListItem,RunItem : Tlistitem;
TemListView : TListView;
ListItemPtr : PListItem;
TabDataPtr : pTabData;
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);
if pFileItem(RunItem.Data).fType=IsDir 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;
ViewStyle := vssmallicon;
SmallImages := imagelist1;
MultiSelect := true;
//FlatScrollBars := true;
DragMode := dmAutomatic;
//BorderStyle := bsNone;
OnMouseDown := BrowseListViewMouseDown; //##$$##
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -