📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Menus,ShellAPI,ShlObj,registry,strutils;
type
TForm1 = class(TForm)
RichEdit1: TRichEdit;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
procedure RichEdit1Change(Sender: TObject);
procedure RichEdit1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure N1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
g:string;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.RichEdit1Change(Sender: TObject);
var f:string;
i:integer;
const
h:array[1..9] of string=('\','/',':','*','?','"',
'<','>','|');
begin
if g='' then
g:='c:\';
richedit1.Text:=trim(richedit1.Text);
f:=richedit1.Lines[0];
for i:=1 to 9 do
f:=ansireplacetext(f,h[i],'');
if f<>'' then
begin
if length(widestring(f))>35 then
f:=copy(widestring(f),1,35);
richedit1.lines.SaveToFile(g+'\'+f+'.txt');
//richedit1.lines.SaveToFile(g+'\'+f+'.doc');
end;
richedit1.Clear;
end;
procedure TForm1.RichEdit1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
begin
ReleaseCapture;
Perform(WM_SYSCOMMAND, $F012, 0);
end;
end;
//退出
procedure TForm1.N1Click(Sender: TObject);
begin
close;
end;
//任务栏隐藏
procedure TForm1.FormCreate(Sender: TObject);
var ff:tregistry;
begin
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
form1.Width:=25;
ff:=tregistry.Create;
with ff do
begin
rootkey:=HKEY_LOCAL_MACHINE;
if openkey('Software\Microsoft\Windows\CurrentVersion\websave',false) then
g:=readstring('Websave');
closekey;
destroy;
end;
end;
//选择保存目录
procedure TForm1.N3Click(Sender: TObject);
var
TitleName : string;
lpItemID : PItemIDList;
BrowseInfo : TBrowseInfo;
DisplayName : array[0..MAX_PATH] of char;
TempPath : array[0..MAX_PATH] of char;
//目录注册表保存
ff:tregistry;
begin
FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
BrowseInfo.hwndOwner := Form1.Handle;
BrowseInfo.pszDisplayName := @DisplayName;
TitleName := '请选择保存目录:';
BrowseInfo.lpszTitle := PChar(TitleName);
BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
lpItemID := SHBrowseForFolder(BrowseInfo);
if lpItemId <> nil then begin
SHGetPathFromIDList(lpItemID, TempPath);
g:=TempPath;
GlobalFreePtr(lpItemID);
end;
ff:=tregistry.Create;
with ff do
begin
rootkey:=HKEY_LOCAL_MACHINE;
if openkey('Software\Microsoft\Windows\CurrentVersion\websave',true) then
writestring('Websave',g);
closekey;
destroy;
end;
end;
procedure TForm1.N5Click(Sender: TObject);
begin
form2.ShowModal;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -