?? main.pas
字號(hào):
77 : //背景音樂(lè) "M"
ItemMP3.Click;
86 : //查看剪貼板 "V"
ItemReadClip.Click;
83 : //設(shè)置 "S"
ItemSetup.Click;
78 : //顯示 / 隱藏書(shū)本 "N"
ItemShow.Click;
73 : //最大化顯示 "I"
ItemMax.Click;
90 : //自動(dòng)翻頁(yè)測(cè)試 "Z"
ItemRecordTime.Click;
88 : //退出 "X"
ItemQuit.Click;
67 : //清除最新文件 "C"
ItemClearNewItem.Click;
192 : //單、雙頁(yè)顯示切換 "~"
begin
g_boolSinglePage := not g_boolSinglePage;
Init_Window;
Init_BackImage; //初始化背景圖片
Init_Page;
ChangeYe(g_nYeCurrent);
end;
48..57, 96..105 : //打開(kāi)最新文件 "1..9"
begin
if TimeKeyDelay.Enabled then
begin //轉(zhuǎn)換鍵碼的第二位
if (Key >= 48) and (Key <= 57) then
FnKeyOpenFile := FnKeyOpenFile * 10 + Key - 48
else
FnKeyOpenFile := FnKeyOpenFile * 10 + Key - 96;
//關(guān)閉鍵盤(pán)延時(shí)
TimeKeyDelay.Enabled := False;
end
else
begin //轉(zhuǎn)換鍵碼的第一位
if (Key >= 48) and (Key <= 57) then
FnKeyOpenFile := Key - 48
else
FnKeyOpenFile := Key - 96;
//打開(kāi)鍵盤(pán)延時(shí)
TimeKeyDelay.Enabled := True;
Exit;
end;
//打開(kāi)最新文件
if (FnKeyOpenFile >= 1) and (FnKeyOpenFile <= FstrNewFileList.Count) then
begin
OnItemNewFileClick(ItemNew.Items[FnKeyOpenFile - 1]);
end;
end;
end;
end;
//---窗口隱藏事件---
procedure TFormMain.FormHide(Sender: TObject);
begin
FboolIsMP3Show := FormMP3Play.Visible;
FormMP3Play.Close;
end;
//---窗口關(guān)閉事件---
procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction);
var i : integer;
begin
//保存設(shè)置
//保存書(shū)本設(shè)置
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;
//保存頁(yè)面設(shè)置
RegWriteBool(c_strRegPath, c_strRegBookMoveFlag, g_boolMove); //移動(dòng)窗口標(biāo)志
RegWriteBool(c_strRegPath, c_strRegBookResizeFlag, g_boolResize); //改變窗口大小標(biāo)志
RegWriteBool(c_strRegPath, c_strRegPageMoveFlag, g_boolPageMove); //拖曳頁(yè)面移動(dòng)標(biāo)志
RegWriteBool(c_strRegPath, c_strRegPageYeFlag, g_boolPageYe); //點(diǎn)擊頁(yè)面翻頁(yè)標(biāo)志
RegWriteBool(c_strRegPath, c_strRegMaxFlag, g_boolMax); //最大化顯示標(biāo)志
RegWriteBool(c_strRegPath, c_strRegSinglePage, g_boolSinglePage); //單頁(yè)顯示標(biāo)志
RegWriteBool(c_strRegPath, c_strRegAutoPageMoveFlag, g_boolAutoPageMove); //自動(dòng)翻頁(yè)標(biāo)志
RegWriteInt(c_strRegPath, c_strRegAutoVal, g_nAutoVal); //自動(dòng)翻頁(yè)時(shí)間
RegWriteBool(c_strRegPath, c_strRegUnMimeCodeFlag, g_boolUnMimeCode); //處理UnMimeCode標(biāo)志
RegWriteBool(c_strRegPath, c_strRegUnQPCodeFlag, g_boolUnQPCode); //處理UnQPCode標(biāo)志
RegWriteBool(c_strRegPath, c_strRegUnHZCodeFlag, g_boolUnHZCode); //處理UnHZCode標(biāo)志
RegWriteBool(c_strRegPath, c_strRegBIG5Flag, g_boolBIG5); //處理BIG5碼標(biāo)志
RegWriteBool(c_strRegPath, c_strRegGBFlag, g_boolGB); //處理GB碼標(biāo)志
RegWriteBool(c_strRegPath, c_strRegHtmlFlag, g_boolHtml); //處理html標(biāo)志
RegWriteBool(c_strRegPath, c_strRegChapFlag, g_boolChap); //智能分段標(biāo)志
RegWriteBool(c_strRegPath, c_strRegHangDFlag, g_boolHangD); //行距加倍標(biāo)志
RegWriteBool(c_strRegPath, c_strRegUnderLineFlag, g_boolUnderLine); //下劃線標(biāo)志
RegWriteInt(c_strRegPath, c_strRegUnderLineColor, g_nUnderLineColor); //下劃線顏色
RegWriteInt(c_strRegPath, c_strRegUnderLineOffset, g_nUnderLineOffset); //下劃線的距離
RegWriteInt(c_strRegPath, c_strRegUnderLineThick, g_nUnderLineThick); //下劃線的寬度
//保存頁(yè)碼設(shè)置
RegWriteStr(c_strRegPath, c_strRegYe1Be, g_strYe1Be); //頁(yè)碼1的前綴
RegWriteStr(c_strRegPath, c_strRegYe1Af, g_strYe1Af); //頁(yè)碼1的后綴
RegWriteStr(c_strRegPath, c_strRegYe1Loc, g_strYe1Loc); //頁(yè)碼1的位置
RegWriteBool(c_strRegPath, c_strRegYe1Count, g_boolYe1Count); //顯示頁(yè)碼1的總頁(yè)碼標(biāo)志
RegWriteStr(c_strRegPath, c_strRegYe2Be, g_strYe1Be); //頁(yè)碼2的前綴
RegWriteStr(c_strRegPath, c_strRegYe2Af, g_strYe1Af); //頁(yè)碼2的后綴
RegWriteStr(c_strRegPath, c_strRegYe2Loc, g_strYe2Loc); //頁(yè)碼2的位置
RegWriteBool(c_strRegPath, c_strRegYe2Count, g_boolYe2Count); //顯示頁(yè)碼2的總頁(yè)碼標(biāo)志
//保存界面設(shè)置
RegWriteBool(c_strRegPath, c_strRegBackBmpFlag, g_boolBackImage); //背景圖片標(biāo)志
RegWriteStr(c_strRegPath, c_strRegBackBmpFilename, g_strBackImageFilename); //背景圖片文件
RegWriteBool(c_strRegPath, c_strRegLabelImageFlag, g_boolLabelImage); //書(shū)簽圖片標(biāo)志
RegWriteStr(c_strRegPath, c_strRegLabelImageFilename, g_strLabelImageFilename); //書(shū)簽圖片文件
RegWriteBool(c_strRegPath, c_strRegShowTime, g_boolShowTime); //顯示時(shí)間標(biāo)志
for i := 1 to c_nAlarmMax do
begin
RegWriteBool(c_strRegAlarmPath, c_strRegAlarmFlag + IntToStr(i), g_boolAlarm[i]); //定時(shí)提醒標(biāo)志
RegWriteStr(c_strRegAlarmPath, c_strRegAlarmTime + IntToStr(i), TimeToStr(g_AlarmTime[i])); //定時(shí)提醒時(shí)間
RegWriteStr(c_strRegAlarmPath, c_strRegAlarmMsg + IntToStr(i), g_strAlarmMsg[i]); //定時(shí)提醒內(nèi)容
end;
RegWriteBool(c_strRegPath, c_strRegBtnFlat, g_boolFlat); //浮動(dòng)式按鈕標(biāo)志
RegWriteBool(c_strRegPath, c_strRegViewCtrl, g_boolViewCtrl); //顯示界面控制按鈕標(biāo)志
//保存系統(tǒng)設(shè)置
RegWriteBool(c_strRegPath, c_strRegItemChangeFlag, g_boolChangeItem); //最新文件菜單改變順序標(biāo)志
RegWriteBool(c_strRegPath, c_strRegOpenFileFlag, g_boolOpenCloseFile); //打開(kāi)上次關(guān)閉時(shí)候的文件標(biāo)志
if (g_strFilename <> '') and (g_strFilename <> '說(shuō)明文件') and (g_strFilename <> '剪貼板') then
begin //有打開(kāi)的文件,則將該文件寫(xiě)入注冊(cè)表
RegWriteStr(c_strRegFilePath, c_strRegCloseFilename, g_strFilename);
RegWriteInt(c_strRegFilePath, c_strRegCloseFilenameIndex, FnOpenNewIndex);
RegWriteInt(c_strRegFilePath, c_strRegCloseFilenameYe, g_nYeCurrent + FnYeOffset);
end
else
begin //沒(méi)有打開(kāi)的文件,則將空記錄寫(xiě)入注冊(cè)表
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); //清除書(shū)簽信息標(biāo)志
RegWriteBool(c_strRegPath, c_strRegClearNewFlag, g_boolClearNewItem); //清除最新文件信息標(biāo)志
RegWriteBool(c_strRegPath, c_strRegSimpleItem, g_boolSimpleItem); //簡(jiǎn)化最新文件菜單
RegWriteBool(c_strRegPath, c_strRegAutoGB, g_boolAutoGB); //自動(dòng)轉(zhuǎn)換為GB/BIG5碼
RegWriteBool(c_strRegPath, c_strRegYeViewFlag, g_boolYeView); //頁(yè)碼顯示標(biāo)志
//保存頁(yè)碼字體設(shè)置
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); //字體語(yǔ)言
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); //下劃線
//保存頁(yè)面字體設(shè)置
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); //字體語(yǔ)言
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); //最大容納的文件容量
//恢復(fù)窗口狀態(tài)
FboolBookResizeFlag := True;
FormMain.Hide;
FormMain.WindowState := wsNormal;
//返回當(dāng)前目錄
ChDir(g_strAppCurrentDir);
//刪除臨時(shí)ZIP目錄
DeleteDirectory(g_strZipPassDir);
end;
//--------------------------------菜單事件--------------------------------------
//---右鍵主菜單彈出事件---
procedure TFormMain.MenuMainPopup(Sender: TObject);
var i : integer;
begin
//調(diào)整最新文件菜單
ItemNew.Enabled := (FstrNewFileList.Count > 0);
//調(diào)整默認(rèn)最新文件
if (FstrNewFileList.Count > 0) then
begin
if (FnOpenNewIndex >= 0) and (FnOpenNewIndex <= FstrNewFileList.Count - 1) then
begin
ItemNew.Items[FnOpenNewIndex].Default := True;
end
else
begin
ItemNew.Items[0].Default := True;
ItemNew.Items[0].Default := False;
end;
end;
//調(diào)整文件處理菜單
ItemBIG5.Checked := g_boolBIG5;
ItemGB.Checked := g_boolGB;
ItemHtml.Checked := g_boolHtml;
ItemChap.Checked := g_boolChap;
ItemHangD.Checked := g_boolHangD;
ItemUnderLine.Checked := g_boolUnderLine;
//調(diào)整編碼處理菜單
ItemUnMimeCode.Checked := g_boolUnMimeCode;
ItemUnQPCode.Checked := g_boolUnQPCode;
ItemUnHZCode.Checked := g_boolUnHZCode;
//調(diào)整書(shū)簽菜單
ItemLabel.Enabled := (g_strFilename <> '') and (g_strFilename <> '剪貼板');
ItemAddLabel.Enabled := not FboolCurrentLabel;
ItemEditLabel.Enabled := FboolCurrentLabel;
ItemDeleteLabel.Enabled := FboolCurrentLabel;
ItemLabelInput.Enabled := ItemLabel.Enabled and (ItemLabelInput.Count > 0);
//調(diào)整默認(rèn)書(shū)簽
if ItemLabelInput.Enabled then
begin
for i := 0 to ItemLabelInput.Count - 1 do
begin
if g_boolSinglePage then
ItemLabelInput.Items[i].Default := (g_nYeCurrent + FnYeOffset = FnLabelIndex[i])
else
ItemLabelInput.Items[i].Default := (g_nYeCurrent = FnLabelIndex[i]) or (g_nYeCurrent + 1 = FnLabelIndex[i]);
end;
end;
//調(diào)整指定頁(yè)菜單
ItemInputYe.Enabled := (g_nYeCount > 2);
//調(diào)整自動(dòng)翻頁(yè)菜單
ItemAutoPageMove.Checked := g_boolAutoPageMove;
ItemAutoPageMove.Caption := '自動(dòng)翻頁(yè)(' + IntToStr(g_nAutoVal) + '秒)';
//調(diào)整背景音樂(lè)菜單
ItemMP3.Enabled := g_boolExistMP3;
//調(diào)整顯示菜單
if FormMain.Visible then
ItemShow.Caption := '隱藏書(shū)本'
else
ItemShow.Caption := '顯示書(shū)本';
//調(diào)整最大化顯示菜單
g_boolMax := (FormMain.WindowState = wsMaximized);
if g_boolMax then
ItemMax.Caption := '恢復(fù)顯示'
else
ItemMax.Caption := '最大化顯示';
//調(diào)整測(cè)試自動(dòng)翻頁(yè)菜單
if FboolTestAutoPage then
ItemRecordTime.Caption := '結(jié)束自動(dòng)翻頁(yè)測(cè)試...'
else
ItemRecordTime.Caption := '開(kāi)始自動(dòng)翻頁(yè)測(cè)試';
//調(diào)整清除最新文件菜單
ItemClearNewItem.Enabled := (FstrNewFileList.Count > 0);
end;
//---打開(kāi)文件菜單---
procedure TFormMain.ItemOpenClick(Sender: TObject);
var nOpenFileIndex : integer; //打開(kāi)文件索引
nOpenFileCount : integer; //打開(kāi)文件總數(shù)
begin
//顯示主窗口
ShowMainForm;
//打開(kāi)對(duì)話框,錯(cuò)誤則退出
with FDlgOpenTextFile do
begin
if isZipSubFile(g_strFilename) then
InitialDir := ExtractFilePath(Copy(g_strFilename, 1, pos(c_strZipSpilt, g_strFilename) - 1))
else
InitialDir := ExtractFilePath(g_strFilename);
if not Execute then
Exit;
end;
//刷新主窗口
UpdateMainForm;
//設(shè)置參數(shù)
FboolOpenFileFlag := False; //寫(xiě)標(biāo)志:沒(méi)有正確打開(kāi)文件
FboolOpenLibFile := False; //寫(xiě)標(biāo)志:沒(méi)有打開(kāi)書(shū)庫(kù)文件
FnOpenFileCount := 0; //文件計(jì)數(shù)寫(xiě)0
//獲得總文件數(shù)
nOpenFileCount := FDlgOpenTextFile.Files.Count;
if nOpenFileCount > c_nRegFilenameCount then
nOpenFileCount := c_nRegFilenameCount;
for nOpenFileIndex := nOpenFileCount - 1 downto 0 do
OpenItemFile(FDlgOpenTextFile.Files.Strings[nOpenFileIndex]); //打開(kāi)菜單文件(僅把文件寫(xiě)入菜單)
//判斷是否打開(kāi)了書(shū)庫(kù)文件,并且刪除原最新菜單
if FboolOpenFileFlag and FboolOpenLibFile and g_boolClearNewItem then
begin
//刪除最新文件菜單
for nOpenFileIndex := FnOpenFileCount to FstrNewFileList.Count - 1 do
DeleteNewItem(FnOpenFileCount);
//改變最新文件索引
if FnOpenNewIndex >= FnOpenFileCount then
FnOpenNewIndex := -1;
end;
//正確打開(kāi)文件,則打開(kāi)參數(shù)文件中第一個(gè)文件
if FboolOpenFileFlag then
begin
OnItemNewFileClick(ItemNew.Items[0]);
end;
end;
//---保存文件菜單---
procedure TFormMain.ItemSaveClick(Sender: TObject);
var i, j : integer;
s : string;
begin
//顯示主窗口
ShowMainForm;
//打開(kāi)對(duì)話框,錯(cuò)誤則退出
with FDlgSaveTextFile do
begin
if isZipSubFile(g_strFilename) then
InitialDir := ExtractFilePath(Copy(g_strFilename, 1, pos(c_strZipSpilt, g_strFilename) - 1))
else
InitialDir := ExtractFilePath(g_strFilename);
if not Execute then
Exit;
end;
//獲得文件名
s := FDlgSaveTextFile.Filename;
//保存文件
try
AssignFile(FpFile, s);
FileMode := 1;
Rewrite(FpFile, 1);
//初始化顯示信息
InitShowMess(0, FnCountTextRead, '保存文件');
for i := 1 to FnCountTextRead do
begin
//顯示完成度信息
ShowMessPos(i);
//寫(xiě)文件
for j := 1 to Length(FstrTextReadReady[i]) do
FstrDataBuf[j] := FstrTextReadReady[i][j];
BlockWrite(FpFile, FstrDataBuf, Length(FstrTextReadReady[i]), FnReadnum);
end;
except
Alert('保存文件 ' + s + ' 失敗!' + c_strReturn + '請(qǐng)檢查磁盤(pán)是否錯(cuò)誤。');
end;
//關(guān)閉文件
CloseFile(FpFile);
//關(guān)閉顯示信息
CloseShowMess;
end;
//---打開(kāi)最新文件---
procedure TFormMain.OnItemNewFileClick(Sender: TObject);
var
strFilename : string; //打開(kāi)的文件名
strZipFileList : TStringList; //用于傳送解壓文件的文件列表
strZipFilename, strZipSubFilename : string; //ZIP文件名、子文件名
i : integer;
procedure InitOpenFile;
var
nCurrentLabel, nCountLabel : integer;
begin //初始化打開(kāi)的文件
//初始化打開(kāi)文件的索引的文件名
FnOpenNewIndex := TMenuItem(Sender).MenuIndex;
g_strFilename := strFilename;
//初始化處理設(shè)置
if (LowerCase(ExtractFileExt(strFilename)) = '.htm') or
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -