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

📄 formmainunit.pas

📁 duiwenjiandechuli fangbianguanli.
💻 PAS
📖 第 1 页 / 共 5 页
字号:

procedure TFormMain.CutButtonClick(Sender: TObject);
begin
  Richedit.CutToClipboard;
end;

procedure TFormMain.CopyButtonClick(Sender: TObject);
begin
  Richedit.CopyToClipboard;
end;

procedure TFormMain.PasteButtonClick(Sender: TObject);
begin
  RichEdit.PasteFromClipboard;
end;

procedure TFormMain.UndoButtonClick(Sender: TObject);
begin
  with Richedit do
    if HandleAllocated then
      SendMessage(Handle, EM_UNDO, 0, 0);
end;

procedure TFormMain.richEditURLClick(Sender: TObject;
  const URLText: string; Button: TMouseButton);
begin
  if button = MbLeft then
  begin
    ShellExecute(handle, 'open', PANsiChar(URLTEXT), nil, nil, 1);
  end;
end;

procedure TFormMain.SubMenu_EditInsertTABClick(Sender: TObject);
begin
  Sendkeys('TAB', false);
end;

procedure TFormMain.SubMenu_EditInsertSysTimeClick(Sender: TObject);
var
  Times             : string;
begin
  Times := DateTimeToStr(Now);
  Sendkeys(PChar(Times), false);
end;

procedure TFormMain.SubMenu_EditInsertHRClick(Sender: TObject);
begin
  Sendkeys('----------------------------------------------------------------',
    false);
  Sendkeys(PChar(#13#10), false);
end;

procedure TFormMain.SubMenu_EditInsertFileLinkClick(Sender: TObject);
var
  filePath          : string;
begin
  OpenDialog1.Filter := '任意文件(*.*)|*.*';
  if OpenDialog1.Execute then
  begin
    filePath := OpenDialog1.FileName;
    filePath := FastReplace(filePath, #32, '%20', false);
    SendKeys(PChar('file:///' + filePath + ''), false);
  end;
end;

procedure TFormMain.SubMenu_EditInsertDirLinkClick(Sender: TObject);
var
  filePath          : string;
begin
  filePath := '';
  SelectDirectory('请选择要链接的目录', '', filePath);
  if filePath = '' then
    Exit;
  filePath := FastReplace(filePath, #32, '%20', false);
  SendKeys(PChar('file:///' + filePath + ''), false);
end;

procedure TFormMain.SubMenu_EditInsertTextClick(Sender: TObject);
var
  filePath          : string;
  tmpTls            : TStrings;
begin
  OpenDialog1.Filter := '文本文件(*.txt)|*.txt';
  if opendialog1.Execute then
  begin
    filePath := opendialog1.FileName;
    tmpTls := TStringlist.Create;
    tmpTls.LoadFromFile(filePath);
    Clipboard.AsText := tmpTls.Text;
    richEdit.PasteFromClipboard;
    tmpTLs.Free;
  end;
end;

procedure TFormMain.richEditMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  TP                : TPoint;
begin
  if Button = mbright then
  begin
    GetCurSorPos(TP);
    EditPopupMenu.Popup(tp.x, tp.y);
  end;
end;

procedure TFormMain.Bmp1Click(Sender: TObject);
var
  Bmp               : TBitmap;
begin
  if not OpenPictureDialog1.Execute then
    exit;
  Bmp := TBitmap.Create;
  try
    try
      Bmp.LoadFromFile(OpenPictureDialog1.FileName);
      Clipboard.Assign(BMP);
      richEdit.PasteFromClipboard;
    except
      application.MessageBox('对不起,该版本目前只支持BMP位图引入!',
        '系统提示', mb_ok or mb_IconInformation);
    end;
  finally
    Bmp.Free;
  end;
end;

procedure TFormMain.SubMenu_EditInsertOLEClick(Sender: TObject);
begin
  if not richEdit.InsertObjectDialog then
    application.MessageBox('无法插入OLE对象!', '错误', mb_ok or mb_Iconerror);
end;

procedure TFormMain.SubMenu_EditToolsPntSelClick(Sender: TObject);
begin
  ExecPrintText;
end;

procedure TFormMain.SubMenu_EditToolsPntTxtClick(Sender: TObject);
begin
  RichEdit.Print(DateTimeToStr(Now()));
end;

procedure TFormMain.SubMenu_EditToolsCodeColorClick(Sender: TObject);
begin
  Clipboard.Clear;
  RichEdit.CopyToClipboard;
  FormSetCodeColor := TFormSetCodeColor.Create(nil);
  FormSetCodeColor.showModal;
  FormSetCodeColor.free;
end;

procedure TFormMain.SubMenu_EditToolsSaveAsImgClick(Sender: TObject);
begin
  FormRichESaveToBmp := TFormRichESaveToBmp.Create(nil);
  FormRichESaveToBmp.ShowModal;
  FormRichESaveToBmp.free;
end;

procedure TFormMain.SubMenu_FileImportClick(Sender: TObject);
var
  tmpQuery          : TADOQuery;
  fileSize          : string;
  fStm              : TFileStream;
begin
  OpenDialog1.Filter := '任意文件(*.*)|*.*';
  if OpenDialog1.Execute then
  begin
    fStm := TFileStream.Create(OpenDialog1.FileName, fmOpenRead);
    fileSize := InttoStr(fStm.Size);
    fStm.Free;
    tmpQuery := TADOQuery.Create(nil);
    tmpQuery.Connection := ADOConnection1;
    with tmpQuery do
    begin
      Close;
      Sql.Clear;
      SQL.Add('Insert into InfoFile(FileBin,FileName,FileSize,InfoID)values(:FileBin,:FileName,:FileSize,:InfoID)');
      //复制一份
      CopyFile(PAnsiChar(OpenDialog1.FileName), PAnsiChar(OpenDialog1.FileName +
        '.ex'), false);
      //压缩
      compressstream(OpenDialog1.FileName + '.ex');
      //保存到
      tmpQuery.Parameters.ParamByName('fileBin').LoadFromFile(OpenDialog1.FileName + '.ex', ftBlob);
      tmpQuery.Parameters.ParamByName('fileName').DataType := ftString;
      tmpQuery.Parameters.ParamByName('fileSize').DataType := ftstring;
      tmpQuery.Parameters.ParamByName('infoID').DataType := ftInteger;
      tmpQuery.Parameters.ParamByName('fileName').Value :=
        ExtractFileName(OpenDialog1.FileName);
      tmpQuery.Parameters.ParamByName('fileSize').Value := fileSize;
      tmpQuery.Parameters.ParamByName('infoID').Value := self.InfoID;
      try
        ExecSQL;
        DeleteFile(OpenDialog1.FileName + '.ex');
        application.MessageBox('保存完毕!', '提示信息', 48);
      except
        on e: exception do
        begin
          application.MessageBox(pchar('保存文件失败!' + #13 + #13 +
            e.message), '错误信息', 16);
          Exit;
        end;
      end;
      tmpQuery.Free;
    end;
  end;
  DisplayFileList(self.InfoID);
end;

procedure TFormMain.SubMenu_FileExportClick(Sender: TObject);
begin
  if filelist.Selected = nil then
    Exit;
  SaveDialog1.Filter := '任意文件(*' + ExtractFileExt(fileList.Selected.Caption)
    + ')|*' + ExtractFileExt(fileList.Selected.Caption);
  if SaveDialog1.Execute then
    DBOLDSaveToFile(ChangeFileExt(SaveDialog1.FileName,
      ExtractFileExt(fileList.Selected.Caption)),
      strToInt(FileList.Selected.SubItems.Strings[1]));
end;

procedure TFormMain.SubMenu_FileOpenOtherClick(Sender: TObject);
var
  ExecName          : string;
  exitCode          : DWORD;
begin
  if filelist.Selected = nil then
    Exit;
  ExecName := GetExePath + 'files\' +
    ChangeFileExt(RandomFileName(fileList.Selected.Caption),
    ExtractFileExt(fileList.Selected.Caption));
  FormMain.WindowState := wsMinimized;
  exitCode := 0;
  DBOLDSaveToFile(execName, strToInt(FileList.Selected.SubItems.Strings[1]));
  if ansicomparetext('.exe', ExtractFileExt(fileList.Selected.Caption)) = 0 then
  begin
    try
      RunExeFile(ExecName, ExecName,
        ExtractFileDir(ExecName),
        exitCode);
    finally
      DeleteFile(ExecName);
      FormMain.WindowState := wsNormal;
      if exitCode <> 0 then
      begin
        application.MessageBox(PAnsiChar(format('返回状态码: %d', [exitCode])),
          '执行文件结果', mb_ok or mb_IconInformation);
      end;
    end;
  end
  else
  begin
    FormMain.Enabled := false;
    FormWaitForTmpFile := TFormWaitForTmpFile.Create(nil);
    //    FormWaitForTmpFile.WindowState := wsMinimized;
    FormWaitForTmpFile.execName := execName;
    FormWaitForTmpFile.autoID :=
      strToInt(FileList.Selected.SubItems.Strings[1]);
    shellExecute(handle, 'open', pansiChar(execName), nil, nil, 1);
    SetActiveWIndow(GetActiveWIndow);
    FormWaitForTmpFile.Show;
    FormWaitForTmpFile.Left := 0;
    FormWaitForTmpFile.Top := Screen.Height - FormWaitForTmpFile.Height - 50;
  end;
end;

procedure TFormMain.FormResize(Sender: TObject);
begin
  if FormWaitForTmpFile <> nil then
    FormWaitForTmpFile.WindowState := wsNormal;
end;

procedure TFormMain.FileListDblClick(Sender: TObject);
begin
  SubMenu_FileOpenOtherClick(sender);
end;

procedure TFormMain.TypeTreeChange(Sender: TObject; Node: TTreeNode);
begin
  richEdit.Color := clWhite;
end;

procedure TFormMain.SpeedButton4Click(Sender: TObject);
begin
  Splitter2.Visible := false;
  Panel2.Visible := false;
end;

procedure TFormMain.ToolButton5Click(Sender: TObject);
begin
  if Application.MessageBox('真的打算删除该篇文章?', '提示', mb_ok or mb_YESNO
    or Mb_IconInformation) = IDYES then
    with TypeQuery do
    begin
      Close;
      SQL.Text := 'delete from InfoContent where AutoID=:AutoID';
      TypeQuery.Parameters.ParamByName('AutoID').DataType := ftInteger;
      TypeQuery.Parameters.ParamByName('AutoID').Value := self.InfoID;
      try
        ExecSQL;
        self.InfoID := 0;
        richEdit.Clear;
        richEdit.Color := clwhite;
        richEdit.Modified := false;
        cLose;
      except
        Application.MessageBox('无法删除', '提示', mb_ok or mb_IconInformation);
      end;
    end;
end;

procedure TFormMain.tbEditModeClick(Sender: TObject);
begin
  tbWBMode.Down := not tbEditMode.Down;
  SetEditMode(tbEditMode.Down);
end;

procedure TFormMain.tbWbModeClick(Sender: TObject);
var
  execname          : string;
begin
  tbEditMode.Down := not tbWBMode.Down;
  SetEditMode(tbEditMode.Down);
  if filelist.Selected = nil then
    execName := ''
  else
  begin
    ExecName := GetExePath + 'files\' +
      ChangeFileExt(RandomFileName(fileList.Selected.Caption),
      ExtractFileExt(fileList.Selected.Caption));
    DBOLDSaveToFile(execName, strToInt(FileList.Selected.SubItems.Strings[1]));
  end;
  tmpFileName := execname;
  showHtml(execName);
end;

procedure TFormMain.ToolButton13Click(Sender: TObject);
begin
  FormMain.WindowState := wsMinimized;
  FormMain.Hide;
  RxTrayIcon1.Active := true;

end;

procedure TFormMain.ToolButton1Click(Sender: TObject);
begin
  if Application.MessageBox('清空当前文本?', '提示', mb_ok or mb_YESNO
    or Mb_IconInformation) = IDYES then
    richEdit.Clear;
end;

procedure TFormMain.N10Click(Sender: TObject);
begin
  tbEditMode.down := false;
  tbwbMode.Down := true;
  SetEditMode(tbEditMode.Down);
  tbWbModeClick(Sender);
end;

procedure TFormMain.SubMenu_FileOpenSelfClick(Sender: TObject);
var
  execname          : string;
  tFile             : TFileStream;
begin
  tbEditMode.down := true;
  tbwbMode.Down := false;
  SetEditMode(tbEditMode.Down);
  if filelist.Selected = nil then
    Exit;
  ExecName := GetExePath + 'files\' +
    ChangeFileExt(RandomFileName(fileList.Selected.Caption),
    ExtractFileExt(fileList.Selected.Caption));
  DBOLDSaveToFile(execName, strToInt(FileList.Selected.SubItems.Strings[1]));

  tmpFileName := execname;

  tFile := tFileStream.Create(execName, fmOpenRead);
  richEdit.Lines.LoadFromStream(Tfile);
  richEdit.Modified := false;
  richEdit.Color := clwhite;
end;

procedure TFormMain.Submenu_TrayIconShowClick(Sender: TObject);
begin
  if FormMain.Showing then
    formMain.Hide
  else
    formMain.Show;
  if FormMain.WindowState = wsMinimized then
    FormMain.WindowState := wsNormal
  else
    FormMain.WindowState := wsMinimized;
end;

procedure TFormMain.SubMenu_FileDeleteClick(Sender: TObject);
begin
  if filelist.Selected = nil then
    Exit;
  if Application.MessageBox('删除选中附件?', '提示', mb_ok or mb_YESNO
    or Mb_IconInformation) = IDYES then
    with TypeQuery do
    begin
      close;
      sql.text := 'delete from InfoFile where autoID=:autoID';
      TypeQuery.Parameters.ParamByName('AutoID').DataType := ftInteger;
      TypeQuery.Parameters.ParamByName('AutoID').Value :=
        strToInt(FileList.Selected.SubItems.Strings[1]);
      TypeQuery.Prepared;
      try

⌨️ 快捷键说明

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