⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.pas

📁 delphi 电子书阅读器 外观非常漂亮
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{
模块名称:全局变量定义

使用方法:无

返回值:  无
}

unit Global;

interface

uses
	SysUtils, Controls, Forms, Windows, Graphics, Registry, stdctrls,
	Language, ZipPassword;

	
//--------------------------------------常量------------------------------------
const
	c_nAlarmMax = 4;  //定时提醒最大数目
  	c_strRegSoundPath = 'Software\Tale\ReadBook\Sound';  //背景音乐目录

	//---注册音乐设置---
	c_strRegSoundFilename = '背景音乐文件';
	c_strRegSoundRepeat = '重复播放';

	//---系统常量---
	c_strLanguageDLL = 'BookLanguage.dll';  //系统默认语言库文件
	c_strReturn = #13#10;   //回车、换行
	c_strZipSpilt = '|';    //ZIP文件的分隔符
	c_strItemMore = '...';  //菜单格式

	
//--------------------------------------变量------------------------------------
var
	//系统变量
	//多语言变量
	g_boolUseLanguageDLL : boolean;
	g_hDLL : THandle;
	GetLanguageCharset : function : integer; stdcall;
	GetLanguageWord : function(index : integer) : PWideChar; stdcall;
	GetLanguageReadme : function : PWideChar; stdcall;

	//注册表变量
	g_Regini : TRegIniFile;

	//文件变量
	g_strFilename : string = '';       //当前打开的文件名

	//MP3变量
	g_boolExistMP3 : Boolean = False;  //是否存在MP3控件

	//Zip变量
	g_strZipPassDir : string;          //zip文件临时解压目录(传递给unzip的目录)
	g_strZipPassDirChar : array[1 .. 100] of Char;  //用于得到系统的临时目录(如:c:\windows\temp)

	g_strAppCurrentDir : string;           //应用程序当前目录
	g_boolSystemCall : Boolean = False;    //系统调用标志(用于暂时屏蔽某些消息)
	g_MousePoint : TPoint;                 //当前鼠标位置

	//系统设置变量
	g_boolChangeMax : Boolean = False;     //是否改变最大化显示设置
	g_boolChangeWindow : Boolean = False;  //是否改变窗口设置
	g_boolChangePage : Boolean = False;    //是否改变页面设置
	g_boolChangeYe : Boolean = False;      //是否改变页码设置
	g_boolChangePageDo : Boolean = False;  //是否改变处理设置
	g_boolChangeImage : Boolean = True;    //是否改变背景设置

	//书本设置变量
	g_nBookLeft : integer;             //窗口左位置
	g_nBookTop : integer;              //窗口上位置
	g_nBookWidth : integer;            //窗口宽度
	g_nBookHeight : integer;           //窗口高度

	g_nYeCount : integer = 0;          //总页码
	g_nYeCurrent : integer = 0;        //当前页码
	g_nCountWord : integer = 0;        //总字数

	g_nOldYeCurrent : integer = 0;     //翻页前的当前页码

	//页面设置变量
	g_boolMove : boolean;              //移动窗口标志
	g_boolResize : boolean;            //改变窗口大小标志
	g_boolPageMove : boolean;          //点击页面移动窗口标志
	g_boolPageYe : boolean;            //点击页面翻页标志
	g_boolMax : boolean;               //最大化显示标志
	g_boolMaxYe : boolean;             //最大化显示翻页标志
	g_boolSinglePage : boolean;        //单页显示标志
	g_boolAutoPageMove : boolean;      //自动翻页标志
	g_nAutoVal : integer;              //自动翻页时间

	g_boolUnMimeCode : boolean;        //处理UnMimeCode标志
	g_boolUnQPCode : boolean;          //处理UnQPCode标志
	g_boolUnHZCode : boolean;          //处理UnHZCode标志
	g_boolBIG5 : boolean;              //处理BIG5标志
	g_boolGB : boolean;                //处理GB标志
	g_boolHtml : boolean;              //处理Html标志
	g_boolChap : boolean;              //处理智能分段标志
	g_boolHangD : boolean;             //处理加倍行距标志
	g_boolUnderLine : boolean;         //显示下划线标志
	g_nUnderLineColor : Integer;       //下划线的颜色
	g_nUnderLineOffset : Integer;      //下划线的距离
	g_nUnderLineThick : Integer;       //下划线的宽度

	//页码设置变量
	g_strYe1Be : string;               //页码1前缀
	g_strYe1Af : string;               //页码1后缀
	g_strYe1Loc : string;              //页码1位置参数
	g_boolYe1Count : boolean;          //页码1显示总页数

	g_strYe2Be : string;               //页码2前缀
	g_strYe2Af : string;               //页码2后缀
	g_strYe2Loc : string;              //页码2位置参数
	g_boolYe2Count : boolean;          //页码2显示总页数

	//界面设置变量
	g_boolBackImage : boolean;         //使用背景图片标志
	g_strBackImageFilename : string;   //背景图片文件名
	g_boolLabelImage : boolean;        //使用书签图片标志
	g_strLabelImageFilename : string;  //书签图片文件名
	g_boolShowTime : boolean;          //显示时间标志
	g_boolAlarm   : array [1 .. c_nAlarmMax] of Boolean;    //每次定时提醒标志
	g_AlarmTime   : array [1 .. c_nAlarmMax] of TDateTime;  //每次定时提醒时间
	g_strAlarmMsg : array [1 .. c_nAlarmMax] of string;     //每次定时提醒内容
	g_boolFlat : boolean;              //浮动按钮标志
	g_boolViewCtrl : boolean;          //显示界面控制图标标志

	//系统设置变量
	g_boolChangeItem : boolean;        //改变最新文件菜单标志
	g_boolOpenCloseFile : boolean;     //打开关闭时候的文件标志
	g_boolClearLabel : boolean;        //清除书签标志
	g_boolClearNewItem : boolean;      //清除最新文件菜单标志
	g_boolSimpleItem : boolean;        //简化最新文件菜单

	g_boolAutoGB : boolean;            //自动转换为GB/BIG5码
	g_boolCheckText : boolean;         //校验文件错误
	g_boolSaveTempFile : boolean;      //关闭时保存临时文件
	g_strLanguageDLL : string;         //外挂语言库文件
	g_boolYeView : boolean;            //显示页码标志
	g_YeFont : TFont;                  //页码字体
	g_PageFont : TFont;                //页面字体

	g_nMaxFileRead : integer;          //最大容纳的文件容量
	g_nMaxTextRead : integer;          //最大容纳的文本框数


//--------------------------------------函数------------------------------------
	//---多语言函数---
	procedure LoadLanguageDLL;
	procedure UnloadLanguageDLL;
	function  GetCharset : TFontCharset;
	function  GetWord(CurrentWord : string) : string;
	function  GetReadme : string;

	//---转换函数---
	function  CheckTxt(CheckText : string) : string;
	function  HtmlToTxt(HtmlString : string) : string;
	function  ChapTxt(TxtString : string; ListChap1, ListChap2 : TListBox) : string;
	procedure ReplaceSubString(SubString, ReplaceString : string; var s : string);

	//---得到当前鼠标信息---
	procedure GetCurrentMousePoint;

	//---消息框---
	procedure Prompt(Msg : string);
	procedure Alert(Msg : string);
	function  Confirm(Msg : string) : boolean;

	//---注册表---
	function  RegReadInt(Section, Ident : string; Default : integer = 0) : integer;
	function  RegReadStr(Section, Ident : string; Default : string = '') : string;
	function  RegReadBool(Section, Ident : string; Default : boolean = False) : boolean;
	procedure RegWriteInt(Section, Ident : string; Value : integer = 0);
	procedure RegWriteStr(Section, Ident : string; Value : string = '');
	procedure RegWriteBool(Section, Ident : string; Value : boolean = False);
	procedure RegEraseSection(Section : string);

	//---系统函数---
	function GetAppPath : string;
	function GetZipPassword(var s : string) : boolean;


//--------------------------------------实现------------------------------------
implementation

//---多语言函数---
procedure LoadLanguageDLL;
begin
	g_boolUseLanguageDLL := False;

	if ((g_strLanguageDLL = '') or (not FileExists(g_strLanguageDLL))) then
	begin
		if (FileExists(GetAppPath + c_strLanguageDLL)) then
			g_strLanguageDLL := GetAppPath + c_strLanguageDLL
		else
			g_strLanguageDLL := '';
	end;

	if (g_strLanguageDLL <> '') then
	begin
		g_hDLL := LoadLibrary(PChar(g_strLanguageDLL));
		g_boolUseLanguageDLL := (g_hDLL >= 32);

		if (g_boolUseLanguageDLL) then
		begin
			@GetLanguageCharset := GetProcAddress(g_hDLL, 'GetLanguageCharset');
			@GetLanguageWord := GetProcAddress(g_hDLL, 'GetLanguageWord');
			@GetLanguageReadme := GetProcAddress(g_hDLL, 'GetLanguageReadme');
		end;
	end;
end;

procedure UnloadLanguageDLL;
begin
	if (g_boolUseLanguageDLL) then
	begin
		GetLanguageCharset := nil;
		GetLanguageWord := nil;
		GetLanguageReadme := nil;

		FreeLibrary(g_hDLL);
		g_boolUseLanguageDLL := False;
	end;
end;

function GetCharset : TFontCharset;
var
	n : integer;
begin
	if (g_boolUseLanguageDLL) then
	begin
		n := GetLanguageCharset;
	end
	else
	begin
		n := 134;  //GB2312_CHARSET	
	end;

	Result := TFontCharset(n);
end;

function GetWord(CurrentWord : string) : string;
var
	s : WideString;
begin
	if (g_boolUseLanguageDLL) then
	begin
		s := GetLanguageWord(FormLanguage.ListBoxLanguage.Items.IndexOf(CurrentWord));
	end
	else
	begin
		s := CurrentWord;
	end;

	Result := s;
end;

function GetReadme : string;
var
	s : WideString;
begin
	if (g_boolUseLanguageDLL) then
	begin
		s := GetLanguageReadme;
	end
	else
	begin
		s := FormLanguage.MemoReadme.Lines.Text;
	end;

	Result := s;
end;

//---转换函数---
function CheckTxt(CheckText : string) : string;
var
	strTextReadDo : string;   //处理一部分文本框的字符串
	boolEndChange : Boolean;  //处理结束标志
	nChangeIndex : integer;   //转换位置
	j, k, L : integer;
begin
	strTextReadDo := CheckText;  //初始化转换文本框
	boolEndChange := False;      //写标志:没有完成处理
	nChangeIndex := 1;           //从第1位开始搜索

	while not boolEndChange do
	begin
		//搜索错误的换行
		L := Length(strTextReadDo);
		j := pos(#10, Copy(strTextReadDo, nChangeIndex, L - nChangeIndex + 1));
		k := pos(#13, Copy(strTextReadDo, nChangeIndex, L - nChangeIndex + 1));

		if ((j = 0) and (k = 0)) or (nChangeIndex > L) then
			boolEndChange := True  //结束搜索
		else
		begin
			if ((j < k) or (k = 0)) and (j <> 0) then
			begin  //非正常换行,在前插入#13
				Insert(#13, strTextReadDo, nChangeIndex + j - 1);
				inc(j);
			end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -