📄 main.pas
字号:
TextRead[i].Text:='';
TextRead_Ready[i]:='';
TextRead_Bak[i]:='';
end;
end;
procedure Tf_main.FormShow(Sender: TObject);
begin
if First_Boot then
begin //第一次启动
First_Boot:=False; //写标志:非第一次启动
Init; //初始化设置
//取消设置有效标志
f_ye.ye_check.Checked:=False;
f_setup.setup_check.Checked:=False;
end;
Pop_Show.Caption:='隐藏书本';
if mp3Show then f_mp3play.Show;
end;
procedure Tf_main.FormHide(Sender: TObject);
begin
Pop_Show.Caption:='显示书本';
mp3Show:=f_mp3play.Visible;
f_mp3play.Close;
end;
procedure Tf_main.Init();
var ParmFileIndex : longint; //参数文件索引
begin
Init_Var; //初始化系统变量
xtsub:=True; //若为系统调用,则退出
Init_Max; //调整最大化显示
xtsub:=False; //若为系统调用,则退出
Init_Window; //初始化窗口
Openfile_Flag:=False; //写标志:不是正确打开文件
if ParamStr(1)='' then
begin //无参数文件
//判断是否打开说明文件
if (f_setup.Check_OpenFile.Checked) and (Pop_new.Count>2) and
(Close_Filename<>'') and (Close_Filename_Index>=0) and (Close_Filename_ye>0) then
begin //打开上次关闭时候的文件
j:=0;
Close_Filename_Index:=-1; //初始化打开文件的索引
While (j<=Pop_new.Count-1-2) do
begin //判断上次关闭时的文件是否在最新文件菜单中
s1:=LowerCase(Pop_new.Items[j].Caption);
s1:=Copy(s1,Length(IntToStr(j+1))+Length(Pop_New_Index)+1,Length(s1)-(Length(IntToStr(j+1))+Length(Pop_New_Index))); //去除索引
if Lowercase(Close_Filename)=LowerCase(s1) then
begin //已经存在相同文件
Close_Filename_Index:=j;
break;
end;
inc(j); //下一个文件
end;
if (Close_filename_index<>-1) then
begin //在最新文件列表中,则打开索引中的文件
pOpenNew_Index:=Close_filename_index; //最新文件索引
OpenNewFile; //打开最新文件
end
else
begin //不在最新文件列表中,则打开参数文件
OpenNew_parm:=True; //写标志:打开参数文件
pFileName:=Close_Filename; //菜单文件名
OpenFile; //打开文件
end;
end;
if not Openfile_Flag then
begin //没有正确打开文件,则打开说明文件
Filename:=''; //初始化打开文件名
Init_Page; //初始化页面
Init_Page_String; //初始化页面内容
Init_ye; //初始化页码
end
else //正确打开文件,则翻到上次关闭时候的页码
Changeye(Close_Filename_ye);
//退出循环
exit;
end
else
begin //打开参数文件
//逐个打开参数文件
Open_File_Count:=0; //文件计数写0
Open_blf_File:=False; //写标志:不是打开书库文件
//从参数中取出完整的文件名
ParmFileIndex:=ParamCount;
while (ParmFileIndex>=1) do
begin
pFileName:='';
//调整带空格的文件名
while (copy(pFileName,1,2)<>'\\') and (copy(pFileName,2,1)<>':') and (ParmFileIndex>=1) do
begin
if pFileName='' then
pFileName:=ParamStr(ParmFileIndex)
else
pFileName:=ParamStr(ParmFileIndex)+' '+pFileName;
dec(ParmFileIndex);
end;
Open_Param_File(pFileName); //打开参数文件
end;
//判断是否打开了书库文件,并且删除原最新菜单
if (Open_blf_File) and (f_setup.Check_ClearNew.Checked) then
for ParmFileIndex:=Open_File_Count to Pop_new.Count-1-2 do
Delete_NewItem(Open_File_Count);
end;
if not Openfile_Flag then
begin //打开参数文件失败,则打开说明文件
Filename:=''; //初始化打开文件名
Init_Page; //初始化页面
Init_Page_String; //初始化页面内容
Init_ye; //初始化页码
end
else
begin //打开参数文件中的第一个文件
OpenFirstFile;
end;
end;
procedure Tf_main.Init_Var();
var Reg_Flag : string; //注册标志
RegBookPath : string; //注册表路径
begin
//注册快捷菜单
//打开注册表
Reg_ini := TRegIniFile.Create('');
Reg_ini.RootKey:=HKEY_CLASSES_ROOT;
RegBookPath:='Book Files'; //定义注册表中路径
//注册软件
Reg_ini.WriteString(RegBookPath,'','电子小说阅读器');
Reg_ini.WriteString(RegBookPath+'\DefaultIcon','',ParamStr(0)+',0');
Reg_ini.WriteString(RegBookPath+'\Shell\使用电子小说阅读器阅读(&R)\command','',ParamStr(0)+' %1');
//注册右键快捷菜单
Reg_ini.WriteString('\.'+Lib_File,'',RegBookPath);
s1:='\'+Reg_ini.ReadString('\.txt','','txtfile');
Reg_ini.WriteString(s1+'\shell\使用电子小说阅读器阅读(&R)\command','',ParamStr(0)+' %1');
s1:='\'+Reg_ini.ReadString('\.htm','','htmlfile');
Reg_ini.WriteString(s1+'\shell\使用电子小说阅读器阅读(&R)\command','',ParamStr(0)+' %1');
s1:='\'+Reg_ini.ReadString('\.html','','htmlfile');
Reg_ini.WriteString(s1+'\shell\使用电子小说阅读器阅读(&R)\command','',ParamStr(0)+' %1');
s1:='\'+Reg_ini.ReadString('\.rtf','','rtffile');
Reg_ini.WriteString(s1+'\shell\使用电子小说阅读器阅读(&R)\command','',ParamStr(0)+' %1');
s1:='\'+Reg_ini.ReadString('\.ini','','inifile');
Reg_ini.WriteString(s1+'\shell\使用电子小说阅读器阅读(&R)\command','',ParamStr(0)+' %1');
//注册参数
Reg_ini.RootKey:=HKEY_LOCAL_MACHINE;
//注册版本号
Reg_ini.WriteString(Reg_Path,Reg_reg_ver,ver);
//更新旧版本的注册
if Reg_ini.ReadString(Reg_Path,Reg_Filename+'0','')<>'' then //存在旧版本最新文件
for i:=0 to Reg_Filename_Count-1 do
begin //将旧版本中的最新文件转移到新版本的路径下,并删除旧版本的最新文件
tempFileName:=Reg_ini.ReadString(Reg_Path,Reg_Filename+IntToStr(i),'');
Reg_ini.WriteString(Reg_File_Path,Reg_Filename+IntToStr(i),tempFileName);
Reg_ini.DeleteKey(Reg_Path,Reg_Filename+IntToStr(i));
end;
//更新最新文件索引
if Reg_ini.ReadInteger(Reg_File_Path,Reg_Filename_Sort+'0',-1)=-1 then
for i:=0 to Reg_Filename_Count-1 do
begin //建立默认索引
Reg_ini.WriteInteger(Reg_File_Path,Reg_Filename_Sort+IntToStr(i),i);
end;
//判断是否注册
Reg_Flag:=Reg_ini.ReadString(Reg_Path,Reg_Reg_Flag,''); //读注册标志
if Reg_Flag<>'Tale' then
begin //未注册、则注册
//注册窗口位置、大小
Reg_ini.WriteInteger(Reg_Path,Reg_Book_Left,Book_Left);
Reg_ini.WriteInteger(Reg_Path,Reg_Book_Top,Book_Top);
Reg_ini.WriteInteger(Reg_Path,Reg_Book_Width,Book_Width+40);
Reg_ini.WriteInteger(Reg_Path,Reg_Book_Height,Book_Height);
//注册页码位置、前缀、后缀
Reg_ini.WriteString(Reg_Path,Reg_ye_1_loc,'12');
Reg_ini.WriteString(Reg_Path,Reg_ye_1_be,'第');
Reg_ini.WriteString(Reg_Path,Reg_ye_1_af,'页');
Reg_ini.WriteString(Reg_Path,Reg_ye_2_loc,'32');
Reg_ini.Writestring(Reg_Path,Reg_ye_2_be,'第');
Reg_ini.WriteString(Reg_Path,Reg_ye_2_af,'页');
//注册页面字体设置
Reg_ini.WriteString(Reg_Font_Path,Reg_page_Font_Name,pageFont.Font.Name);
Reg_ini.WriteInteger(Reg_Font_Path,Reg_page_Font_Size,pageFont.Font.Size);
Reg_ini.WriteInteger(Reg_Font_Path,Reg_page_Font_Color,pageFont.Font.Color);
Reg_ini.WriteInteger(Reg_Font_Path,Reg_page_Font_Charset,pageFont.Font.Charset);
Reg_ini.WriteBool(Reg_Font_Path,Reg_Page_Font_Style_1,fsBold in pageFont.Font.Style);
Reg_ini.WriteBool(Reg_Font_Path,Reg_Page_Font_Style_2,fsItalic in pageFont.Font.Style);
Reg_ini.WriteBool(Reg_Font_Path,Reg_Page_Font_Style_3,fsStrikeOut in pageFont.Font.Style);
Reg_ini.WriteBool(Reg_Font_Path,Reg_Page_Font_Style_4,fsUnderline in pageFont.Font.Style);
//注册页码字体设置
Reg_ini.WriteString(Reg_Font_Path,Reg_ye_Font_Name,yeFont.Font.Name);
Reg_ini.WriteInteger(Reg_Font_Path,Reg_ye_Font_Size,yeFont.Font.Size);
Reg_ini.WriteInteger(Reg_Font_Path,Reg_ye_Font_Color,yeFont.Font.Color);
Reg_ini.WriteInteger(Reg_Font_Path,Reg_ye_Font_Charset,yeFont.Font.Charset);
Reg_ini.WriteBool(Reg_Font_Path,Reg_ye_Font_Style_1,fsBold in yeFont.Font.Style);
Reg_ini.WriteBool(Reg_Font_Path,Reg_ye_Font_Style_2,fsItalic in yeFont.Font.Style);
Reg_ini.WriteBool(Reg_Font_Path,Reg_ye_Font_Style_3,fsStrikeOut in yeFont.Font.Style);
Reg_ini.WriteBool(Reg_Font_Path,Reg_ye_Font_Style_4,fsUnderline in yeFont.Font.Style);
//注册系统设置
Reg_ini.WriteBool(Reg_Path,Reg_Book_Move_Flag,True); //移动窗口标志
Reg_ini.WriteBool(Reg_Path,Reg_Book_Resize_Flag,True); //改变窗口大小标志
Reg_ini.WriteBool(Reg_Path,Reg_Page_Move_Flag,True); //拖曳页面移动标志
Reg_ini.WriteBool(Reg_Path,Reg_Page_ye_Flag,True); //点击页面翻页标志
Reg_ini.WriteBool(Reg_Path,Reg_Max_Flag,False); //最大化显示标志
Reg_ini.WriteBool(Reg_Path,Reg_ye_view_Flag,True); //页码显示标志
Reg_ini.WriteBool(Reg_Path,Reg_Item_Change_Flag,False); //最新文件菜单改变顺序标志
Reg_ini.WriteBool(Reg_Path,Reg_Openfile_Flag,True); //打开上次关闭时候的文件标志
Reg_ini.WriteBool(Reg_Path,Reg_BackBmp_Flag,False); //背景图片标志
Reg_ini.WriteString(Reg_Path,Reg_BackBmp_Filename,''); //背景图片文件
Reg_ini.WriteBool(Reg_Path,Reg_Label_Image_Flag,False); //书签图片标志
Reg_ini.WriteString(Reg_Path,Reg_Label_Image_Filename,''); //书签图片文件
Reg_ini.WriteString(Reg_Sound_Path,Reg_Sound_Filename+'0',''); //背景音乐文件
Reg_ini.WriteBool(Reg_Sound_Path,Reg_Sound_Repeat,False); //背景音乐重复播放标志
Reg_ini.WriteBool(Reg_Path,Reg_Auto_Page_Move_Flag,False); //自动翻页标志
Reg_ini.WriteInteger(Reg_Path,Reg_AutoVal,0); //自动翻页时间
Reg_ini.WriteBool(Reg_Path,Reg_ClearLab_Flag,True); //清除书签信息
Reg_ini.WriteBool(Reg_Path,Reg_ClearNew_Flag,True); //清除最新文件信息
Reg_ini.WriteBool(Reg_Path,Reg_ShowTime,True); //显示时间标志
Reg_ini.WriteBool(Reg_Path,Reg_Flat,False); //浮动式按钮标志
for i:=1 to Alarm_Max do
begin
Reg_ini.WriteBool(Reg_Alarm_Path,Reg_Alarm_Flag+IntToStr(i),False); //定时提醒标志
Reg_ini.WriteString(Reg_Alarm_Path,Reg_Alarm_Time+IntToStr(i),'00:00:00'); //定时提醒时间
Reg_ini.WriteString(Reg_Alarm_Path,Reg_Alarm_Msg+IntToStr(i),'不要长时间盯着屏幕,注意用眼卫生。'); //定时提醒内容
end;
//注册处理设置
Reg_ini.WriteBool(Reg_Path,Reg_BIG5_Flag,False); //处理BIG5码标志
Reg_ini.WriteBool(Reg_Path,Reg_GB_Flag,False); //处理GB码标志
Reg_ini.WriteBool(Reg_Path,Reg_html_Flag,False); //处理html标志
Reg_ini.WriteBool(Reg_Path,Reg_Chap_Flag,False); //智能分段标志
Reg_ini.WriteBool(Reg_Path,Reg_HangD_Flag,False); //行距加倍标志
Reg_ini.WriteBool(Reg_Path,Reg_UnderLine_Flag,False); //下划线标志
Reg_ini.WriteInteger(Reg_Path,Reg_UnderLine_Color,clRed); //下划线颜色
Reg_ini.WriteInteger(Reg_Path,Reg_UnderLine_Offset,0); //下划线距离
Reg_ini.WriteInteger(Reg_Path,Reg_UnderLine_Thick,1); //下划线宽度
//注册上次关闭时候的文件
Reg_ini.WriteString(Reg_File_Path,Reg_Close_Filename,'');
Reg_ini.WriteInteger(Reg_File_Path,Reg_Close_Filename_Index,0);
Reg_ini.WriteInteger(Reg_File_Path,Reg_Close_Filename_ye,0);
//注册Tale
Reg_ini.WriteString(Reg_Path,Reg_Reg_Flag,'Tale');
end;
//初始化窗口位置、大小
Book_Left_v:=Reg_ini.ReadInteger(Reg_Path,Reg_Book_Left,Book_Left);
Book_Top_v:=Reg_ini.ReadInteger(Reg_Path,Reg_Book_Top,Book_Top);
Book_Width_v:=Reg_ini.ReadInteger(Reg_Path,Reg_Book_Width,Book_Width);
Book_Height_v:=Reg_ini.ReadInteger(Reg_Path,Reg_Book_Height,Book_Height);
Book_Resize_Flag:=True; //不允许改变窗口大小
f_main.Left:=Book_Left_v;
f_main.Top:=Book_Top_v;
f_main.Width:=Book_Width_v;
f_main.Height:=Book_Height_v;
Book_Resize_Flag:=False; //允许改变窗口大小
//初始化页码变量
f_setup.ye_1_loc.Caption:=Reg_ini.ReadString(Reg_Path,Reg_ye_1_loc,'12');
ye_1_be.Caption:=Reg_ini.ReadString(Reg_Path,Reg_ye_1_be,'第');
ye_1_af.Caption:=Reg_ini.ReadString(Reg_Path,Reg_ye_1_af,'页');
f_setup.ye_2_loc.Caption:=Reg_ini.ReadString(Reg_Path,Reg_ye_2_loc,'32');
ye_2_be.Caption:=Reg_ini.ReadString(Reg_Path,Reg_ye_2_be,'第');
ye_2_af.Caption:=Reg_ini.ReadString(Reg_Path,Reg_ye_2_af,'页');
//初始化页面字体设置
PageFont.Font.Name:=Reg_ini.ReadString(Reg_Font_Path,Reg_Page_Font_Name,PageFont.Font.Name);
PageFont.Font.Size:=Reg_ini.ReadInteger(Reg_Font_Path,Reg_Page_Font_Size,PageFont.Font.Size);
PageFont.Font.Color:=Reg_ini.ReadInteger(Reg_Font_Path,Reg_page_Font_Color,pageFont.Font.Color);
PageFont.Font.Charset:=Reg_ini.ReadInteger(Reg_Font_Path,Reg_page_Font_Charset,pageFont.Font.Charset);
tf1:=Reg_ini.ReadBool(Reg_Font_Path,Reg_Page_Font_Style_1,fsBold in pageFont.Font.Style);
tf2:=Reg_ini.ReadBool(Reg_Font_Path,Reg_Page_Font_Style_2,fsItalic in pageFont.Font.Style);
tf3:=Reg_ini.ReadBool(Reg_Font_Path,Reg_Page_Font_Style_3,fsStrikeOut in pageFont.Font.Style);
tf4:=Reg_ini.ReadBool(Reg_Font_Path,Reg_Page_Font_Style_4,fsUnderline in pageFont.Font.Style);
pageFont.Font.Style:=[];
if tf1 then pageFont.Font.Style:=pageFont.Font.Style+[fsBold];
if tf2 then pageFont.Font.Style:=pageFont.Font.Style+[fsItalic];
if tf3 then pageFont.Font.Style:=pageFont.Font.Style+[fsStrikeOut];
if tf4 then pageFont.Font.Style:=pageFont.Font.Style+[fsUnderline];
//初始化页码字体设置
yeFont.Font.Name:=Reg_ini.ReadString(Reg_Font_Path,Reg_ye_Font_Name,yeFont.Font.Name);
yeFont.Font.Size:=Reg_ini.ReadInteger(Reg_Font_Path,Reg_ye_Font_Size,yeFont.Font.Size);
yeFont.Font.Color:=Reg_ini.ReadInteger(Reg_Font_Path,Reg_ye_Font_Color,yeFont.Font.Color);
yeFont.Font.Charset:=Reg_ini.ReadInteger(Reg_Font_Path,Reg_ye_Font_Charset,yeFont.Font.Charset);
tf1:=Reg_ini.ReadBool(Reg_Font_Path,Reg_ye_Font_Style_1,fsBold in yeFont.Font.Style);
tf2:=Reg_ini.ReadBool(Reg_Font_Path,Reg_ye_Font_Style_2,fsItalic in yeFont.Font.Style);
tf3:=Reg_ini.ReadBool(Reg_Font_Path,Reg_ye_Font_Style_3,fsStrikeOut in yeFont.Font.Style);
tf4:=Reg_ini.ReadBool(Reg_Font_Path,Reg_ye_Font_Style_4,fsUnderline in yeFont.Font.Style);
yeFont.Font.Style:=[];
if tf1 then yeFont.Font.Style:=yeFont.Font.Style+[fsBold];
if tf2 then yeFont.Font.Style:=yeFont.Font.Style+[fsItalic];
if tf3 then yeFont.Font.Style:=yeFont.Font.Style+[fsStrikeOut];
if tf4 then yeFont.Font.Style:=yeFont.Font.Style+[fsUnderline];
//初始化系统设置
Book_Move.Enabled:=Reg_ini.ReadBool(Reg_Path,Reg_Book_Move_Flag,True); //初始化移动窗口标志
Book_Resize.Enabled:=Reg_ini.ReadBool(Reg_Path,Reg_Book_Resize_Flag,True); //初始化改变窗口大小标志
f_setup.Check_Page_Move.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_Page_Move_Flag,True); //初始化拖曳页面移动标志
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -