📄 main.pas
字号:
Application.Restore;
FormMain.BringToFront;
FormMain.Update;
end;
//---窗口改变大小事件---
procedure TFormMain.FormResize(Sender: TObject);
begin
//判断是否允许改变窗口大小
if FboolBookResizeFlag then Exit;
//判断窗口不能过小
if FormMain.Width < 2 * FnBookButtonWidth + 100 then
FormMain.Width := 2 * FnBookButtonWidth + 100;
if FormMain.Height < 3 * FnBookButtonWidth + 40 then
FormMain.Height := 3 * FnBookButtonWidth + 40;
//调整窗口位置、大小变量
g_nBookLeft := FormMain.Left;
g_nBookTop := FormMain.Top;
g_nBookWidth := FormMain.Width;
g_nBookHeight := FormMain.Height;
if g_boolSystemCall then Exit; //若为系统调用,则退出
Init_Window; //初始化窗口
Init_Page; //初始化页面
//最大化显示翻页
if g_boolMaxYe then
begin
g_boolMaxYe := False; //写标志:没有最大化显示翻页
ChangeYe(FnCloseFileYe); //翻到关闭时候的页码
end
else
begin
ChangeYe(g_nYeCurrent); //翻到指定页
end;
end;
//---窗口键盘事件---
procedure TFormMain.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
//判断菜单状态
MenuMainPopup(Self);
MenuPageMovePopup(Self);
//判断按键
case Key of
33, 37 : //上一页 "PageUp" "左键"
ItemPagePrev.Click;
34, 39, 32 : //下一页 "PageDown" "右键" "空格"
ItemPageNext.Click;
38 : //上一页 / 行 "上键"
if g_boolUnderLine then
MoveUnderLine(-1)
else
ItemPagePrev.Click;
40 : //下一页 / 行 "下键"
if g_boolUnderLine then
MoveUnderLine(1)
else
ItemPageNext.Click;
36 : //第一页 "Home"
ItemPageFirst.Click;
35 : //最后一页 "End"
ItemPageLast.Click;
8 : //回退到翻页前的一页 "退格键"
ChangeYe(g_nOldYeCurrent);
109, 189 : //上一篇小说(文件) " - "
OpenDiskFile(-1);
107, 187 : //下一篇小说(文件) " + "
OpenDiskFile(1);
188 : //上一篇小说(列表) "<"
ItemFilePrev.Click;
190 : //下一篇小说(列表) ">"
ItemFileNext.Click;
13, 79 : //打开文件 "Enter" "O"
ItemOpen.Click;
84 : //显示 / 隐藏时间 "T"
ShowTime(not g_boolShowTime);
27 : //隐藏窗口 "Esc"
FormMain.Hide;
18 : //弹出Pop菜单 "Alt"
begin
GetCurrentMousePoint;
FormMain.BringToFront;
MenuMain.Popup(g_MousePoint.x, g_MousePoint.y);
end;
66 : //转换为BIG5 "B"
ItemBIG5.Click;
71 : //转换为GB "G"
ItemGB.Click;
72 : //处理HTML "H"
ItemHtml.Click;
70 : //智能分段 "F"
ItemChap.Click;
68 : //行距加倍 "D"
ItemHangD.Click;
85 : //显示下划线 "U"
ItemUnderLine.Click;
69 : //编辑原稿 "E"
ItemEdit.Click;
75 : //生成书库 "K"
ItemLib.Click;
76 : //增加书签 "L"
ItemAddLabel.Click;
89 : //指定页 "Y"
ItemInputYe.Click;
65 : //自动翻页 "A"
ItemAutoPageMove.Click;
77 : //背景音乐 "M"
ItemMP3.Click;
86 : //查看剪贴板 "V"
ItemReadClip.Click;
83 : //设置 "S"
ItemSetup.Click;
78 : //显示 / 隐藏书本 "N"
ItemShow.Click;
73 : //最大化显示 "I"
ItemMax.Click;
90 : //自动翻页测试 "Z"
ItemRecordTime.Click;
88 : //退出 "X"
ItemQuit.Click;
67 : //清除最新文件 "C"
ItemClearNewItem.Click;
192 : //单、双页显示切换 "~"
begin
g_boolSinglePage := not g_boolSinglePage;
Init_Window;
Init_BackImage; //初始化背景图片
Init_Page;
ChangeYe(g_nYeCurrent);
end;
48..57, 96..105 : //打开最新文件 "1..9"
begin
if TimeKeyDelay.Enabled then
begin //转换键码的第二位
if (Key >= 48) and (Key <= 57) then
FnKeyOpenFile := FnKeyOpenFile * 10 + Key - 48
else
FnKeyOpenFile := FnKeyOpenFile * 10 + Key - 96;
//关闭键盘延时
TimeKeyDelay.Enabled := False;
end
else
begin //转换键码的第一位
if (Key >= 48) and (Key <= 57) then
FnKeyOpenFile := Key - 48
else
FnKeyOpenFile := Key - 96;
//打开键盘延时
TimeKeyDelay.Enabled := True;
Exit;
end;
//打开最新文件
if (FnKeyOpenFile >= 1) and (FnKeyOpenFile <= FstrNewFileList.Count) then
begin
ItemNew.Items[FnKeyOpenFile - 1].Click;
end;
end;
end;
end;
//---窗口隐藏事件---
procedure TFormMain.FormHide(Sender: TObject);
begin
FboolIsMP3Show := FormMP3Play.Visible;
FormMP3Play.Close;
end;
//---窗口关闭事件---
procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction);
procedure DelShell(FileExt, FileKind : string);
var
strFileContent : string;
begin
strFileContent := '\' + RegReadStr(FileExt, '', FileKind);
RegEraseSection(strFileContent + '\shell\' + GetWord('使用电子小说阅读器阅读') + '(&R)');
end;
var
i : integer;
begin
//保存设置
//保存书本设置
g_nBookLeft := FormMain.Left; //窗口左位置
g_nBookTop := FormMain.Top; //窗口上位置
g_nBookWidth := FormMain.Width; //窗口宽度
g_nBookHeight := FormMain.Height; //窗口高度
if FormMain.WindowState = wsMaximized then
begin //最大化显示,记录最大化以前备份的位置
RegWriteInt(c_strRegPath, c_strRegBookLeft, FnBookLeftBeMax);
RegWriteInt(c_strRegPath, c_strRegBookTop, FnBookTopBeMax);
RegWriteInt(c_strRegPath, c_strRegBookWidth, FnBookWidthBeMax);
RegWriteInt(c_strRegPath, c_strRegBookHeight, FnBookHeightBeMax);
end
else
begin //正常显示,记录正常的位置
RegWriteInt(c_strRegPath, c_strRegBookLeft, g_nBookLeft);
RegWriteInt(c_strRegPath, c_strRegBookTop, g_nBookTop);
RegWriteInt(c_strRegPath, c_strRegBookWidth, g_nBookWidth);
RegWriteInt(c_strRegPath, c_strRegBookHeight, g_nBookHeight);
end;
//保存页面设置
RegWriteBool(c_strRegPath, c_strRegBookMoveFlag, g_boolMove); //移动窗口标志
RegWriteBool(c_strRegPath, c_strRegBookResizeFlag, g_boolResize); //改变窗口大小标志
RegWriteBool(c_strRegPath, c_strRegPageMoveFlag, g_boolPageMove); //拖曳页面移动标志
RegWriteBool(c_strRegPath, c_strRegPageYeFlag, g_boolPageYe); //点击页面翻页标志
RegWriteBool(c_strRegPath, c_strRegMaxFlag, g_boolMax); //最大化显示标志
RegWriteBool(c_strRegPath, c_strRegSinglePage, g_boolSinglePage); //单页显示标志
RegWriteBool(c_strRegPath, c_strRegAutoPageMoveFlag, g_boolAutoPageMove); //自动翻页标志
RegWriteInt(c_strRegPath, c_strRegAutoVal, g_nAutoVal); //自动翻页时间
RegWriteBool(c_strRegPath, c_strRegUnMimeCodeFlag, g_boolUnMimeCode); //处理UnMimeCode标志
RegWriteBool(c_strRegPath, c_strRegUnQPCodeFlag, g_boolUnQPCode); //处理UnQPCode标志
RegWriteBool(c_strRegPath, c_strRegUnHZCodeFlag, g_boolUnHZCode); //处理UnHZCode标志
RegWriteBool(c_strRegPath, c_strRegBIG5Flag, g_boolBIG5); //处理BIG5码标志
RegWriteBool(c_strRegPath, c_strRegGBFlag, g_boolGB); //处理GB码标志
RegWriteBool(c_strRegPath, c_strRegHtmlFlag, g_boolHtml); //处理html标志
RegWriteBool(c_strRegPath, c_strRegChapFlag, g_boolChap); //智能分段标志
RegWriteBool(c_strRegPath, c_strRegHangDFlag, g_boolHangD); //行距加倍标志
RegWriteBool(c_strRegPath, c_strRegUnderLineFlag, g_boolUnderLine); //下划线标志
RegWriteInt(c_strRegPath, c_strRegUnderLineColor, g_nUnderLineColor); //下划线颜色
RegWriteInt(c_strRegPath, c_strRegUnderLineOffset, g_nUnderLineOffset); //下划线的距离
RegWriteInt(c_strRegPath, c_strRegUnderLineThick, g_nUnderLineThick); //下划线的宽度
//保存页码设置
RegWriteStr(c_strRegPath, c_strRegYe1Be, g_strYe1Be); //页码1的前缀
RegWriteStr(c_strRegPath, c_strRegYe1Af, g_strYe1Af); //页码1的后缀
RegWriteStr(c_strRegPath, c_strRegYe1Loc, g_strYe1Loc); //页码1的位置
RegWriteBool(c_strRegPath, c_strRegYe1Count, g_boolYe1Count); //显示页码1的总页码标志
RegWriteStr(c_strRegPath, c_strRegYe2Be, g_strYe1Be); //页码2的前缀
RegWriteStr(c_strRegPath, c_strRegYe2Af, g_strYe1Af); //页码2的后缀
RegWriteStr(c_strRegPath, c_strRegYe2Loc, g_strYe2Loc); //页码2的位置
RegWriteBool(c_strRegPath, c_strRegYe2Count, g_boolYe2Count); //显示页码2的总页码标志
//保存界面设置
RegWriteBool(c_strRegPath, c_strRegBackBmpFlag, g_boolBackImage); //背景图片标志
RegWriteStr(c_strRegPath, c_strRegBackBmpFilename, g_strBackImageFilename); //背景图片文件
RegWriteBool(c_strRegPath, c_strRegLabelImageFlag, g_boolLabelImage); //书签图片标志
RegWriteStr(c_strRegPath, c_strRegLabelImageFilename, g_strLabelImageFilename); //书签图片文件
RegWriteBool(c_strRegPath, c_strRegShowTime, g_boolShowTime); //显示时间标志
for i := 1 to c_nAlarmMax do
begin
RegWriteBool(c_strRegAlarmPath, c_strRegAlarmFlag + IntToStr(i), g_boolAlarm[i]); //定时提醒标志
RegWriteStr(c_strRegAlarmPath, c_strRegAlarmTime + IntToStr(i), TimeToStr(g_AlarmTime[i])); //定时提醒时间
RegWriteStr(c_strRegAlarmPath, c_strRegAlarmMsg + IntToStr(i), g_strAlarmMsg[i]); //定时提醒内容
end;
RegWriteBool(c_strRegPath, c_strRegBtnFlat, g_boolFlat); //浮动式按钮标志
RegWriteBool(c_strRegPath, c_strRegViewCtrl, g_boolViewCtrl); //显示界面控制按钮标志
//保存系统设置
RegWriteBool(c_strRegPath, c_strRegItemChangeFlag, g_boolChangeItem); //最新文件菜单改变顺序标志
RegWriteBool(c_strRegPath, c_strRegOpenFileFlag, g_boolOpenCloseFile); //打开上次关闭时候的文件标志
if (g_strFilename <> '') and (g_strFilename <> '剪贴板') then
begin //有打开的文件,则将该文件写入注册表
if g_boolSaveTempFile then SaveTempFile(g_strFilename); //保存临时文件
RegWriteStr(c_strRegFilePath, c_strRegCloseFilename, g_strFilename);
RegWriteInt(c_strRegFilePath, c_strRegCloseFilenameIndex, FnOpenNewIndex);
RegWriteInt(c_strRegFilePath, c_strRegCloseFilenameYe, g_nYeCurrent + FnYeOffset);
end
else
begin //没有打开的文件,则将空记录写入注册表
RegWriteStr(c_strRegFilePath, c_strRegCloseFilename, '');
RegWriteInt(c_strRegFilePath, c_strRegCloseFilenameIndex, -1);
RegWriteInt(c_strRegFilePath, c_strRegCloseFilenameYe, 0);
end;
RegWriteBool(c_strRegPath, c_strRegClearLabFlag, g_boolClearLabel); //清除书签信息标志
RegWriteBool(c_strRegPath, c_strRegClearNewFlag, g_boolClearNewItem); //清除最新文件信息标志
RegWriteBool(c_strRegPath, c_strRegSimpleItem, g_boolSimpleItem); //简化最新文件菜单
RegWriteBool(c_strRegPath, c_strRegAutoGB, g_boolAutoGB); //自动转换为GB/BIG5码
RegWriteBool(c_strRegPath, c_strRegCheckText, g_boolCheckText); //校验文件错误
RegWriteBool(c_strRegPath, c_strRegSaveTempFile, g_boolSaveTempFile); //关闭时保存临时文件
RegWriteStr(c_strRegPath, c_strRegLanguageDLL, g_strLanguageDLL); //外挂语言库文件
RegWriteBool(c_strRegPath, c_strRegYeViewFlag, g_boolYeView); //页码显示标志
//保存页码字体设置
RegWriteStr(c_strRegFontPath, c_strRegYeFontName, g_YeFont.Name); //字体名称
RegWriteInt(c_strRegFontPath, c_strRegYeFontSize, g_YeFont.Size); //字体大小
RegWriteInt(c_strRegFontPath, c_strRegYeFontColor, g_YeFont.Color); //字体颜色
RegWriteInt(c_strRegFontPath, c_strRegYeFontCharset, g_YeFont.Charset); //字体语言
RegWriteBool(c_strRegFontPath, c_strRegYeFontStyle1, fsBold in g_YeFont.Style); //粗体
RegWriteBool(c_strRegFontPath, c_strRegYeFontStyle2, fsItalic in g_YeFont.Style); //斜体
RegWriteBool(c_strRegFontPath, c_strRegYeFontStyle3, fsStrikeOut in g_YeFont.Style); //删除线
RegWriteBool(c_strRegFontPath, c_strRegYeFontStyle4, fsUnderline in g_YeFont.Style); //下划线
//保存页面字体设置
RegWriteStr(c_strRegFontPath, c_strRegPageFontName, g_PageFont.Name); //字体名称
RegWriteInt(c_strRegFontPath, c_strRegPageFontSize, g_PageFont.Size); //字体大小
RegWriteInt(c_strRegFontPath, c_strRegPageFontColor, g_PageFont.Color); //字体颜色
RegWriteInt(c_strRegFontPath, c_strRegPageFontCharset, g_PageFont.Charset); //字体语言
RegWriteBool(c_strRegFontPath, c_strRegPageFontStyle1, fsBold in g_PageFont.Style); //粗体
RegWriteBool(c_strRegFontPath, c_strRegPageFontStyle2, fsItalic in g_PageFont.Style); //斜体
RegWriteBool(c_strRegFontPath, c_strRegPageFontStyle3, fsStrikeOut in g_PageFont.Style); //删除线
RegWriteBool(c_strRegFontPath, c_strRegPageFontStyle4, fsUnderline in g_PageFont.Style); //下划线
RegWriteInt(c_strRegPath, c_strRegMaxFileRead, g_nMaxFileRead); //最大容纳的文件容量
//判断是否从注册表中删除电子小说阅读器
if (FboolEraseReg) then
begin
//删除注册书库文件和右键菜单
g_Regini.RootKey := HKEY_CLASSES_ROOT; //暂时改变注册表的根
//删除注册书库文件
RegEraseSection('\.' + c_strLibFile);
RegEraseSection(c_strRegBookPath);
//删除注册右键菜单
DelShell('\.txt', 'txtfile');
DelShell('\.htm', 'htmlfile');
DelShell('\.html', 'htmlfile');
DelShell('\.rtf', 'rtffile');
DelShell('\.ini', 'inifile');
DelShell('\.zip', 'zipfile');
g_Regini.RootKey := HKEY_LOCAL_MACHINE; //还原注册表的根
//删除注册设置
RegEraseSection(c_strRegPath);
end;
//恢复窗口状态
FboolBookResizeFlag := True;
FormMain.Hide;
FormMain.WindowState := wsNormal;
//返回当前目录
ChDir(g_strAppCurrentDir);
//删除临时ZIP目录
DeleteDirectory(g_strZipPassDir);
end;
//--------------------------------菜单事件--------------------------------------
//---右键主菜单弹出事件---
procedure TFormMain.MenuMainPopup(Sender: TObject);
var
i : integer;
boolMenu : boolean;
begin
//判断是否是菜单弹出
boolMenu := (Sender is TPopupMenu);
//调整最新文件菜单
ItemNew.Enabled := (FstrNewFileList.Count > 0);
//调整默认最新文件
if (boolMenu and (FstrNewFileList.Count > 0)) then
begin
if (FnOpenNewIndex >= 0) and (FnOpenNewIndex <= FstrNewFileList.Count - 1) then
begin
ItemNew.Items[FnOpenNewIndex].Default := True;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -