📄 main.pas
字号:
begin
//判断是否是ZIP子文件
if isZipSubFile(strFilename) then
begin
//得到ZIP子文件名
GetZipFilename(strFilename, strFilename1, strFilename);
strFilename := g_strZipPassDir + '\' + strFilename;
end;
SrcStream.LoadFromFile(strFilename);
// DestStream.Position := DestStream.Size;
DestStream.CopyFrom(SrcStream, 0);
end;
end;
DestStream.SaveToFile(s);
finally
SrcStream.Free;
DestStream.Free;
end;
except
Alert(GetWord('生成合并文件') + ' ' + s + ' ' + GetWord('失败!') + c_strReturn + GetWord('请检查磁盘是否错误。'));
end;
//关闭显示信息
CloseShowMess;
end;
//---文件处理菜单---
procedure TFormMain.ItemBIG5Click(Sender: TObject);
var
s : string;
begin
s := TMenuItem(Sender).Name;
if s = 'ItemUnMimeCode' then
begin
g_boolUnMimeCode := not g_boolUnMimeCode;
g_boolUnQPCode := False;
g_boolUnHZCode := False;
end;
if s = 'ItemUnQPCode' then
begin
g_boolUnMimeCode := False;
g_boolUnQPCode := not g_boolUnQPCode;
g_boolUnHZCode := False;
end;
if s = 'ItemUnHZCode' then
begin
g_boolUnMimeCode := False;
g_boolUnQPCode := False;
g_boolUnHZCode := not g_boolUnHZCode;
end;
if s = 'ItemBIG5' then g_boolBIG5 := not g_boolBIG5;
if s = 'ItemGB' then g_boolGB := not g_boolGB;
if s = 'ItemHtml' then g_boolHtml := not g_boolHtml;
if s = 'ItemChap' then g_boolChap := not g_boolChap;
if s = 'ItemHangD' then g_boolHangD := not g_boolHangD;
if s = 'ItemUnderLine' then g_boolUnderLine := not g_boolUnderLine;
ImageUnderLine.Visible := g_boolUnderLine;
if s = 'ItemUnderLine' then
Exit;
if s <> 'ItemHangD' then
Init_Page_Do; //处理页面
//初始化
Init_Page; //初始化页面
ChangeYe(g_nYeCurrent); //翻到指定页
end;
//---编辑菜单---
procedure TFormMain.ItemEditClick(Sender: TObject);
begin
//显示主窗口
ShowMainForm;
FboolEdit := True; //写标志:处于编辑状态
//屏蔽原系统的部分功能
FormMain.PopupMenu := MenuEdit;
FormMain.KeyPreview := False;
ImagePagePrev.Enabled := False;
ImagePageNext.Enabled := False;
ImageUnderLine.Visible := False;
TimeAutoPageMove.Enabled := False;
TimeAutoUnderLine.Enabled := False;
//调整编辑框1
with FMemoPageEdit[1] do
begin
Left := FnPage1Left;
Top := FnPageTop - 3;
Width := FnPageWidth;
Height := FnPageHeight + 3;
Font := g_PageFont;
Visible := True;
end;
//调整编辑框2
with FMemoPageEdit[2] do
begin
Left := FnPage2Left;
Top := FnPageTop - 3;
Width := FnPageWidth;
Height := FnPageHeight + 3;
Font := g_PageFont;
Visible := True;
end;
//复制文字到编辑框
Init_Page_String;
if FMemoPageEdit[1].Visible then
FMemoPageEdit[1].SetFocus
else if FMemoPageEdit[2].Visible then
FMemoPageEdit[2].SetFocus;
end;
//---刷新显示菜单---
procedure TFormMain.ItemRefreshClick(Sender: TObject);
begin
//写标志:使用刷新
FboolUseRefresh := True;
//刷新文件
if (g_strFilename = '') or (g_strFilename = '剪贴板') then
begin //刷新说明文件
Init_Page;
end
else if FnOpenNewIndex >= 0 then
begin //刷新小说文件
ItemNew.Items[FnOpenNewIndex].Click;
end
else
begin //重新打开文件
FboolOpenFileFlag := False; //写标志:没有正确打开文件
OpenItemFile(g_strFilename); //打开菜单文件(仅把文件写入菜单)
//若正确打开文件,则打开参数文件中第一个文件
if FboolOpenFileFlag then
begin
ItemNew.Items[0].Click;
end;
end;
//翻到当前页码
ChangeYe(g_nYeCurrent);
//写标志:不使用刷新
FboolUseRefresh := False;
end;
//---查找菜单---
procedure TFormMain.ItemSearchClick(Sender: TObject);
begin
//显示主窗口
ShowMainForm;
if (FormSearch.ShowModal = mrOk) and (FormSearch.EditFindText.Text <> '') then
DoSearch(FormSearch.EditFindText.Text, FormSearch.CheckBoxCaps.Checked);
end;
//---再查找菜单---
procedure TFormMain.ItemSearchNextClick(Sender: TObject);
begin
//显示主窗口
ShowMainForm;
if FormSearch.EditFindText.Text = '' then
ItemSearch.Click
else
DoSearch(FormSearch.EditFindText.Text, FormSearch.CheckBoxCaps.Checked);
end;
//---添加书签菜单---
procedure TFormMain.ItemAddLabelClick(Sender: TObject);
var
i, j : integer;
begin
//显示主窗口
ShowMainForm;
//当前是说明文件或有书签的话,就退出
if (g_strFilename = '') or (g_strFilename = '剪贴板') or (FboolCurrentLabel) then Exit;
//检测剩余书签数量
j := ItemLabelInput.Count;
if j >= c_nRegLabelCount then
begin
Prompt(GetWord('没有空余书签可供添加,请删除部分书签。'));
Exit;
end;
with TFormLabelInput.Create(Self) do
begin
Caption := GetWord('添加书签');
EditLabelInput.Text := GetWord('第') + IntToStr(g_nYeCurrent + FnYeOffset) + GetWord('页');
if ShowModal = mrOk then
begin
//初始化书签信息
FnLabelIndex[j] := g_nYeCurrent + FnYeOffset;
FstrLabelString[j] := EditLabelInput.Text;
//建立书签子菜单
FItemAddLabel := TMenuItem.Create(Self);
FItemAddLabel.Caption := FstrLabelString[j];
FItemAddLabel.OnClick := OnLabelInputClick;
//调整书签菜单
ItemLabelInput.Add(FItemAddLabel); //添加书签菜单
//将书签信息添加入注册表
//获得最新文件索引
i := RegReadInt(c_strRegFilePath, c_strRegFilenameSort + IntToStr(FnOpenNewIndex), -1);
//写入书签信息
RegWriteInt(c_strRegLabelPath, IntToStr(i) + c_strRegLabel + IntToStr(j), FnLabelIndex[j]);
RegWriteStr(c_strRegLabelPath, IntToStr(i) + c_strRegLabelString + IntToStr(j), FstrLabelString[j]);
//调整书签设置
PanelLabel.Hint := FstrLabelString[j];
ImageLabel.Hint := FstrLabelString[j];
FboolCurrentLabel := True;
PanelLabel.Visible := FboolCurrentLabel;
end;
Free;
end;
end;
//---修改书签菜单---
procedure TFormMain.ItemEditLabelClick(Sender: TObject);
var
i : integer;
begin
//显示主窗口
ShowMainForm;
//当前没有书签的话,就退出
if not FboolCurrentLabel then Exit;
//检测书签
for i := 0 to ItemLabelInput.Count - 1 do
begin
if ((g_boolSinglePage and (g_nYeCurrent + FnYeOffset = FnLabelIndex[i])) or
((not g_boolSinglePage) and ((g_nYeCurrent = FnLabelIndex[i]) or (g_nYeCurrent + 1 = FnLabelIndex[i])))) then
begin //修改书签
with TFormLabelInput.Create(Self) do
begin
Caption := GetWord('修改书签');
EditLabelInput.Text := FstrLabelString[i];
if ShowModal = mrOk then
begin
//调整书签信息
FstrLabelString[i] := EditLabelInput.Text;
ItemLabelInput.Items[i].Caption := FstrLabelString[i];
//将书签信息添加入注册表
RegWriteStr(c_strRegLabelPath,
IntToStr(FnOpenNewIndex) + c_strRegLabelString + IntToStr(i),
FstrLabelString[i]);
//调整书签按钮设置
PanelLabel.Hint := FstrLabelString[i];
ImageLabel.Hint := FstrLabelString[i];
end;
Free;
end;
end;
end;
end;
//---删除书签菜单---
procedure TFormMain.ItemDeleteLabelClick(Sender: TObject);
var
i, j, k : integer;
begin
//显示主窗口
ShowMainForm;
//当前没有书签的话,就退出
if not FboolCurrentLabel then Exit;
//检测书签
for j := 0 to ItemLabelInput.Count - 1 do
begin
if ((g_boolSinglePage and (g_nYeCurrent + FnYeOffset = FnLabelIndex[j])) or
((not g_boolSinglePage) and ((g_nYeCurrent = FnLabelIndex[j]) or (g_nYeCurrent + 1 = FnLabelIndex[j])))) then
begin //删除书签
if Confirm(GetWord('删除书签') + '《' + FstrLabelString[j] + '》' + GetWord('吗?')) then
begin
//获得最新文件索引
i := RegReadInt(c_strRegFilePath, c_strRegFilenameSort + IntToStr(FnOpenNewIndex), - 1);
//调整书签设置
for k := j + 1 to ItemLabelInput.Count - 1 do
begin
FnLabelIndex[k - 1] := FnLabelIndex[k];
FstrLabelString[k - 1] := FstrLabelString[k];
//调整注册表中书签的顺序
RegWriteInt(c_strRegLabelPath, IntToStr(i) + c_strRegLabel + IntToStr(k - 1), FnLabelIndex[k - 1]);
RegWriteStr(c_strRegLabelPath, IntToStr(i) + c_strRegLabelString + IntToStr(k - 1), FstrLabelString[k - 1]);
end;
//写空记录到注册表
k := ItemLabelInput.Count;
FnLabelIndex[k - 1] := 0;
FstrLabelString[k - 1] := '';
RegWriteInt(c_strRegLabelPath, IntToStr(i) + c_strRegLabel + IntToStr(k - 1), FnLabelIndex[k - 1]);
RegWriteStr(c_strRegLabelPath, IntToStr(i) + c_strRegLabelString + IntToStr(k - 1), FstrLabelString[k - 1]);
//删除菜单
ItemLabelInput.Delete(j);
if ItemLabelInput.Count <= 0 then ItemLabelInput.Enabled := False;
//调整书签菜单
FboolCurrentLabel := False;
PanelLabel.Visible := FboolCurrentLabel;
end;
end;
end;
end;
//---指定书签菜单---
procedure TFormMain.OnLabelInputClick(Sender: TObject);
var
i, j : integer;
begin
if ItemLabelInput.Count <=0 then Exit;
j := TMenuItem(Sender).MenuIndex;
if FnLabelIndex[j] > g_nYeCount then
begin //标签指向的页数过大
if Confirm(GetWord('此书签指向一个无效页码,是否删除此书签?')) then
begin
//调整书签设置
for i := j + 1 to ItemLabelInput.Count - 1 do
begin
FnLabelIndex[i - 1] := FnLabelIndex[i];
FstrLabelString[i - 1] := FstrLabelString[i];
//调整注册表中书签顺序
RegWriteInt(c_strRegLabelPath, IntToStr(FnOpenNewIndex) + c_strRegLabel + IntToStr(i - 1), FnLabelIndex[i - 1]);
RegWriteStr(c_strRegLabelPath, IntToStr(FnOpenNewIndex) + c_strRegLabelString + IntToStr(i - 1), FstrLabelString[i - 1]);
end;
//写空记录到注册表
i := ItemLabelInput.Count;
FnLabelIndex[i - 1] := 0;
FstrLabelString[i - 1] := '';
RegWriteInt(c_strRegLabelPath, IntToStr(FnOpenNewIndex) + c_strRegLabel + IntToStr(i - 1), FnLabelIndex[i - 1]);
RegWriteStr(c_strRegLabelPath, IntToStr(FnOpenNewIndex) + c_strRegLabelString + IntToStr(i - 1), FstrLabelString[i - 1]);
//删除菜单
ItemLabelInput.Delete(j);
end;
end
else
begin //书签合法,转到书签的指定页
ChangeYe(FnLabelIndex[j]);
end;
end;
//---指定页码菜单---
procedure TFormMain.ItemInputYeClick(Sender: TObject);
begin
//显示主窗口
ShowMainForm;
if g_nYeCount <= 2 then Exit;
with TFormInputYe.Create(Self) do
begin
if ShowModal = mrOk then
ChangeYe(m_nPos); //转到指定页数
Free;
end;
end;
//---自动翻页菜单---
procedure TFormMain.ItemAutoPageMoveClick(Sender: TObject);
begin
TimeAutoPageMove.Enabled := False; //关闭自动翻页
TimeAutoUnderLine.Enabled := False; //关闭自动移动下划线
g_boolAutoPageMove := not g_boolAutoPageMove;
TimeAutoPageMove.Enabled := g_boolAutoPageMove;
TimeAutoUnderLine.Enabled := g_boolAutoPageMove and g_boolUnderLine;
if g_boolAutoPageMove and g_boolUnderLine then
begin //调整自动下划线状态
ImageUnderLine.Left := FnPage1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -