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

📄 mainform.pas

📁 是一款很不错资料数据库管理软件
💻 PAS
📖 第 1 页 / 共 3 页
字号:
end;

procedure Tmainwin.PopupMenu1Popup(Sender: TObject);
begin
if treeview1.Items.Count=0 then
  begin
  n39.enabled:=false;
  n40.enabled:=false;
  n41.enabled:=false;
  n43.enabled:=false;
  n47.enabled:=false;
  end
else
  begin
  n39.enabled:=true;
  n40.enabled:=true;
  n41.enabled:=true;
  n43.enabled:=true;
  n47.enabled:=true;
  end;
if treeview1.Items.Count=0 then n7.Enabled:=false
else if (treeview1.Selected.Level=0) then n7.Enabled:=false
else n7.Enabled:=true;
if (treeview1.Items.Count=0) or (treeview1.Selected.getFirstChild=nil) then
N47.Enabled:=false else N47.Enabled:=true;
end;

procedure Tmainwin.N38Click(Sender: TObject);
begin
if treeview1.Items.Count<=0 then
with treeview1.items.Addchild(treeview1.topitem,'新增资料项') do
     begin
     imageindex:=0;
     selectedindex:=1;
     selected:=true;
     edittext;
     end
else
if treeview1.Selected=nil then exit
else with treeview1.items.Add(treeview1.selected,'新增资料项') do
     begin
     selected:=true;
     makevisible;
     edittext;
     end;
richedit1.Lines.Clear;
statusbar1.Panels.Items[2].text:='共'+
trim(inttostr(treeview1.items.count))+'条资料';
SpeedButton1.Down:=true;
richedit1.ReadOnly:=false;
treeedited:=true;
end;

procedure Tmainwin.N39Click(Sender: TObject);
begin
if treeview1.Selected=nil then exit;
with treeview1.items.Addchildfirst(treeview1.selected,'新增资料项') do
begin
selected:=true;
makevisible;
edittext;
end;
richedit1.Lines.Clear;
statusbar1.Panels.Items[2].text:='共'+
trim(inttostr(treeview1.items.count))+'条资料';
SpeedButton1.Down:=true;
richedit1.ReadOnly:=false;
treeedited:=true;
end;

procedure Tmainwin.N40Click(Sender: TObject);

    Procedure deltree(Snode:Ttreenode); //删除有下级节点的标题
    var Dnode:Ttreenode;
    begin
    Dnode:=Snode.getFirstChild;
    while Dnode<>nil do
    begin
      if dnode.getFirstChild<>nil then  //如果节点还有子节点
       //begin
       deltree(Dnode);
       //if fileexists(datpath+Dnode.Text+'.sfd') then
       //deletefile(datpath+Dnode.Text+'.sfd');
       //end
      //else
       // begin
        if fileexists(datpath+Dnode.Text+'.sfd') then
        deletefile(datpath+Dnode.Text+'.sfd');
        //end;
    Dnode:=Dnode.getNextSibling;
    end;
    end;
    //-------------------------------- 过程结束
begin
if treeview1.Selected=nil then exit;
if treeview1.Selected.getFirstChild<>nil then
  begin
  if application.MessageBox(pchar('注意!选中的项目('+treeview1.Selected.text+')中还有下级资料,一同删除吗?'),
  '奥博软件',mb_yesno+mb_iconquestion+mb_defbutton2)<>6 then exit;
  deltree(treeview1.Selected);
  end
else
  //begin
  if application.MessageBox(pchar('你要删除['+treeview1.Selected.text+
  ']此条资料吗?'),'奥博软件',mb_yesno+mb_iconquestion+mb_defbutton2)<>6 then exit;
if fileexists(datpath+treeview1.Selected.text+'.sfd') then
deletefile(datpath+treeview1.Selected.text+'.sfd');
treeview1.selected.Delete;
   //end;
statusbar1.Panels.Items[2].text:='共'+
trim(inttostr(treeview1.items.count))+'条资料';
treeedited:=true;
end;

procedure Tmainwin.N41Click(Sender: TObject);
begin
if treeview1.Selected <> nil then
begin
treeview1.selected.EditText;
treeedited:=true;
end;
end;

procedure Tmainwin.TreeView1Changing(Sender: TObject; Node: TTreeNode;
  var AllowChange: Boolean);
begin
if memoedited and (treeview1.Selected<>nil) then
begin
richedit1.Lines.SaveToFile(datpath+trim(treeview1.Selected.Text)+'.sfd');
memoedited:=false;
end;
end;

procedure Tmainwin.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
memoedited:=true;
end;

procedure Tmainwin.N42Click(Sender: TObject);
begin
if fileexists(datpath+trim(treeview1.Selected.text)+'.sfd') then
richedit1.Lines.LoadFromFile(datpath+trim(treeview1.Selected.text)+'.sfd')
end;

procedure Tmainwin.TreeView1Edited(Sender: TObject; Node: TTreeNode;
  var S: String);
begin
if s='' then
begin
showmessage('注意!资料名称不能空!');
s:=Node.Text;
exit;
end;
//------查找是否有系统不接受的文件名字符
if (pos('/',s)>0) or (pos('\',s)>0) or (pos(':',s)>0)
or (pos('*',s)>0) or (pos('?',s)>0) or (pos('"',s)>0)
or (pos('<',s)>0) or (pos('>',s)>0) or (pos('|',s)>0)
then begin
showmessage('注意:你输入了系统不接受的字符做为文件名'+#13+'[/,\,:,*,?,",<,>,|]');
s:=Node.Text;
exit;
end;
if fileexists(datpath+trim(node.text)+'.sfd') then
renamefile(datpath+trim(node.text)+'.sfd',datpath+s+'.sfd');
if fileexists(datpath+s+'.sfd') then
richedit1.lines.LoadFromFile(datpath+s+'.sfd');
treeedited:=true;
end;

//--------选取前一个节点
procedure Tmainwin.SpeedButton5Click(Sender: TObject);
begin
if TreeView1.Selected=nil then exit;
if TreeView1.Selected.GetPrev<>nil then
TreeView1.Selected:=TreeView1.Selected.GetPrev;
end;

//--------------选取下一个节点
procedure Tmainwin.SpeedButton6Click(Sender: TObject);
begin
if TreeView1.Selected=nil then exit;
if TreeView1.Selected.GetNext<>nil then
TreeView1.Selected:=TreeView1.Selected.GetNext;
end;

procedure Tmainwin.N25Click(Sender: TObject);
begin
n25.Checked:=not n25.Checked;
toolbar1.visible:=n25.Checked;
//coolbar1.visible:=n25.Checked;
end;

procedure Tmainwin.N26Click(Sender: TObject);
begin
n26.Checked:=not n26.Checked;
statusbar1.visible:=n26.Checked;
end;

procedure Tmainwin.N27Click(Sender: TObject);
begin
n27.Checked:=not n27.Checked;
//toolbar1.showhint:=n27.Checked;
application.ShowHint:=n27.Checked;
end;

procedure Tmainwin.SpeedButton8Click(Sender: TObject);
begin
richedit1.Font.Size:=richedit1.Font.Size+1;
end;

procedure Tmainwin.SpeedButton7Click(Sender: TObject);
begin
if richedit1.Font.Size >9 then
richedit1.Font.Size:=richedit1.Font.Size-1;
end;

procedure Tmainwin.N2Click(Sender: TObject);
begin
colordialog1.color:=richedit1.font.color;
if colordialog1.Execute then richedit1.font.color:=colordialog1.color;
end;

procedure Tmainwin.ToolButton13Click(Sender: TObject);
begin
if richedit1.Lines.Count=0 then exit;
Finddialog1.execute;
end;

procedure Tmainwin.Finddialog1Find(Sender: TObject);
var
  FoundAt,StartPos,ToEnd:integer;
  SearchFlag:TSearchTypes;
begin
  if frMatchCase in FindDialog1.Options then
    SearchFlag:=SearchFlag+[stMatchCase];
  if frWholeWord in FindDialog1.Options then
    SearchFlag:=SearchFlag+[stWholeWord];
  StartPos:=RichEdit1.SelStart+RichEdit1.SelLength;
  ToEnd:=Length(RichEdit1.Text)-StartPos;
  FoundAt:=RichEdit1.FindText(FindDialog1.FindText,StartPos,ToEnd,
                             SearchFlag);
  if FoundAt<>-1 then
  begin
    RichEdit1.SetFocus;
    RichEdit1.SelStart:=FoundAt;
    RichEdit1.SelLength:=Length(FindDialog1.FindText);
  end
  else
  begin
    MessageBox(Handle,'当前的资料项中找不到输入的字符串!',
    '奥博软件',MB_OK or MB_ICONWARNING);
  end;
end;

procedure Tmainwin.ToolButton11Click(Sender: TObject);
begin
if treeview1.selected=nil then exit;
with savedialog1 do
begin
title:='导出资料项';
filterindex:=1;
defaultext:='TXT';
filter:='文本文件[.TXT]|*.txt|奥博资料库文件[.SFD]|*.sfd';
FileName:=treeview1.Selected.Text;
end;
if savedialog1.Execute then
richedit1.Lines.SaveToFile(savedialog1.FileName);
end;

procedure Tmainwin.ToolButton10Click(Sender: TObject);
begin
if (treeview1.Items.Count>0) and (treeview1.selected=nil) then exit;
with opendialog1 do
begin
title:='导入资料项';
defaultext:='';
filter:='文本文件[.TXT]|*.txt|奥博资料库文件[.SFD]|*.sfd';
FileName:='';
end;
if opendialog1.Execute then
  begin
  if not fileexists(opendialog1.filename) then
    begin
    showmessage('你输入了不存在的文件名!');
    exit;
    end;
  if treeview1.Items.Count>0 then
  with treeview1.Items.Add(treeview1.Selected,
  delext(extractfilename(opendialog1.filename))) do
  selected:=true
  else
  with treeview1.Items.AddChild(treeview1.topitem,
  delext(extractfilename(opendialog1.filename))) do
  begin
  selected:=true;
  SendMessage(TreeView1.Handle,WM_SETREDRAW,-1,0);  //重绘目录树
  end;
  //SendMessage(RichEdit1.Handle,WM_SETREDRAW,0,0);  //禁止重绘
  richedit1.Lines.LoadFromFile(opendialog1.filename);
  //SendMessage(RichEdit1.Handle,WM_SETREDRAW,-1,0);  //重绘目录树
  treeedited:=true;
  memoedited:=true;
  statusbar1.Panels.Items[2].text:='共'+trim(inttostr(treeview1.items.count))+'条资料';
  end;
end;

procedure Tmainwin.SaveDialog1TypeChange(Sender: TObject);
begin
case savedialog1.FilterIndex of
1 : savedialog1.defaultext:='txt';
2 : savedialog1.defaultext:='sdf';
end;
end;

procedure Tmainwin.SpeedButton1Click(Sender: TObject);
begin
richedit1.ReadOnly:= not SpeedButton1.Down;
end;

procedure Tmainwin.N4Click(Sender: TObject);
begin
with toptionform.Create(self) do
begin
showmodal;
free;
end;
end;

procedure Tmainwin.ToolButton1Click(Sender: TObject);
begin
if exteditpro='Notepad.exe' then
winexec('Notepad.exe',sw_showna)
else
if fileexists(exteditpro) then winexec(pchar(exteditpro),sw_showmaximized);
end;
//-----------从目录导入
procedure Tmainwin.N24Click(Sender: TObject);
var
    Nnode:Ttreenode;
    seldir,Noden:string;
    Srec:TSearchRec;
    Retuv:integer;
begin
seldir:=BrowseFolder;
if seldir='' then exit;
Noden:=GetFieldName(seldir);
if seldir[length(seldir)]<>'\' then seldir:=seldir+'\';
Retuv:=findfirst(seldir+'*.txt',FaAnyFile,Srec);
if retuv=0 then
begin
if treeview1.Items.Count=0 then
Nnode:=treeview1.Items.Add(treeview1.topitem,Noden)//formatdatetime('yyyymmddhhnnAM/PM',now))
else
Nnode:=treeview1.Items.Add(treeview1.Selected,Noden);//formatdatetime('yyyymmddhhnnAM/PM',now));
treeedited:=true;
end else exit;
while retuv=0 do
begin
with treeview1.Items.AddChildFirst(Nnode,delext(srec.name)) do makevisible;
copyfile(pchar(seldir+srec.name),pchar(datpath+delext(srec.name)+'.sfd'),true);
retuv:=findnext(srec);
end;
FindClose(Srec);
statusbar1.Panels.Items[2].text:='共'+
trim(inttostr(treeview1.items.count))+'条资料';
end;

⌨️ 快捷键说明

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