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

📄 main.pas

📁 源代码竟供大家参考
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  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_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.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_BIG5_Flag,False);            //处理BIG5码标志
       Reg_ini.WriteBool(Reg_Path,Reg_GB_Flag,False);              //处理BIG5码标志
       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,False);                //行距加倍标志

       Reg_ini.WriteBool(Reg_Path,Reg_UnderLine,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);

  //初始化页码变量
  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,False);      //初始化点击页面移动标志

  if Reg_ini.ReadBool(Reg_Path,Reg_Max_Flag,False) then
     pop_Max.Caption:='恢复显示'
  else
     pop_Max.Caption:='最大化显示';

  f_setup.Check_ye_View.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_ye_view_Flag,True);           //初始化页码显示标志
  f_setup.Check_Item_Change.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_Item_Change_Flag,True);   //初始化改变最新文件菜单顺序标志
  f_setup.Check_Openfile.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_Openfile_Flag,False);        //初始化打开上次关闭时候的文件标志

  f_setup.Check_BackBmp.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_BackBmp_Flag,False);          //初始化背景图片标志
  f_setup.BackBmp.Caption:=Reg_ini.ReadString(Reg_Path,Reg_BackBmp_Filename,'');             //初始化背景图片文件
  f_setup.Check_Label_Image.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_Label_Image_Flag,False);  //初始化书签图片标志
  f_setup.Label_Image.Caption:=Reg_ini.ReadString(Reg_Path,Reg_Label_Image_Filename,'');     //初始化书签图片文件

  f_setup.Check_ClearLab.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_ClearLab_Flag,True);         //初始化清除书签信息标志
  f_setup.Check_ClearNew.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_ClearNew_Flag,True);         //初始化清除最新文件信息标志

  //初始化自动翻页设置
  Auto_Page_Move.Interval:=Reg_ini.ReadInteger(Reg_Path,Reg_AutoVal,0)*1000;                 //初始化自动翻页标志
  Auto_Page_Move.Enabled:=Reg_ini.ReadBool(Reg_Path,Reg_Auto_Page_Move_Flag,False);          //初始化自动翻页时间

  xtsub:=True;   //写标志:进入系统调用
  pop_Auto_Page_Move.Checked:=Auto_Page_Move.Enabled;
  pop_Auto_Page_Move.Caption:='自动翻页('+IntToStr(round(f_main.Auto_Page_Move.Interval/1000))+'秒)';
  xtsub:=False;  //写标志:退出系统调用

  //初始化处理设置
  xtsub:=True;   //写标志:进入系统调用

  pop_BIG5.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_BIG5_Flag,False);  //初始化处理BIG5码标志
  pop_GB.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_GB_Flag,False);      //初始化处理GB码标志
  pop_html.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_html_Flag,False);  //初始化处理html标志
  pop_Chap.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_Chap_Flag,False);  //初始化智能分段标志
  pop_HangD.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_HangD,False);     //初始化行距加倍标志

  pop_UnderLine.Checked:=Reg_ini.ReadBool(Reg_Path,Reg_UnderLine,False);      //初始化下划线标志
  UnderLine_Color:=Reg_ini.ReadInteger(Reg_Path,Reg_UnderLine_Color,clRed);   //下划线颜色
  UnderLine_Offset:=Reg_ini.ReadInteger(Reg_Path,Reg_UnderLine_Offset,0);     //下划线距离
  UnderLine_Thick:=Reg_ini.ReadInteger(Reg_Path,Reg_UnderLine_Thick,1);       //下划线宽度

  xtsub:=False;  //写标志:退出系统调用

  //初始化时间显示设置
  Show_Time.Enabled:=Reg_ini.ReadBool(Reg_Path,Reg_ShowTime,True);
  Time_Panel.Visible:=Show_Time.Enabled;

  //初始化背景图片设置
  if (f_setup.Check_BackBmp.Checked) and (f_setup.BackBmp.Caption<>'') then  //打开背景图片
     try  //尝试打开背景图片
        Book_image.Picture.LoadFromFile(f_setup.BackBmp.Caption);
     except  //打开背景图片失败,则使用系统默认图片
        f_main.Enabled:=False;
        Application.MessageBox(PChar('打开图片文件 '+f_setup.BackBmp.Caption+' 失败!'+#13+#10+
                               '系统将使用默认背景图片。'), '错误', Mb_OK);
        f_main.Enabled:=True;

        f_setup.Check_BackBmp.Checked:=False;
        f_setup.BackBmp.Caption:='';

        Book_Image.Picture:=Back_Image.Picture;
     end
  else  //不使用背景图片,打开系统默认图片
     Book_Image.Picture:=Back_Image.Picture;

  //初始化书签图片设置
  if (f_setup.Check_Label_Image.Checked) and (f_setup.Label_Image.Caption<>'') then  //打开书签图片
     try  //尝试打开书签图片
        Label_Image_Pic.Picture.LoadFromFile(f_setup.Label_Image.Caption);
     except  //打开书签图片失败,则使用系统默认图片
        f_main.Enabled:=False;
        Application.MessageBox(PChar('打开图片文件 '+f_setup.Label_Image.Caption+' 失败!'+#13+#10+
                               '系统将使用默认书签图片。'), '错误', Mb_OK);
        f_main.Enabled:=True;

        f_setup.Check_Label_Image.Checked:=False;
        f_setup.Label_Image.Caption:='';

        Label_image_Pic.Picture:=label_image_1.Picture;
     end
  else  //不使用书签图片,打开系统默认图片
     Label_Image_Pic.Picture:=Label_Image_1.Picture;

  //初始化上次关闭时候的文件设置
  Close_Filename:=Reg_ini.ReadString(Reg_File_Path,Reg_Close_Filename,'');              //初始化文件名
  Close_Filename_Index:=Reg_ini.ReadInteger(Reg_File_Path,Reg_Close_Filename_Index,0);  //初始化文件索引
  Close_Filename_ye:=Reg_ini.ReadInteger(Reg_File_Path,Reg_Close_Filename_ye,0);        //初始化文件页码

  //初始化最新文件菜单
  j:=0;
  while (j<=Reg_Filename_Count-1) do
  begin  //从注册表中逐个读入最新文件
       k:=Reg_ini.ReadInteger(Reg_File_Path,Reg_Filename_Sort+IntToStr(j),-1);       //获得索引值
       tempfilename:=Reg_ini.ReadString(Reg_File_Path,Reg_Filename+IntToStr(k),'');  //获得索引指定的文件名
       if tempfilename<>'' then
       begin  //有最新文件,则加入菜单
            //建立最新文件子菜单
            AddNew:=TMenuItem.Create(Self);
            AddNew.Caption:=tempfilename;
            AddNew.OnClick:=OpenNewClick;

            //更改最新文件菜单设置
            pop_new.Insert(pop_new.Count-2,AddNew);         //添加子菜单
            pop_new.Enabled:=True;                               //允许使用下一级子菜单
            pop_clearnew.Enabled:=True;                          //允许删除最新记录

            //下一个最新文件
            inc(j);
       end
       else  //无最新文件,则退出循环
          break;
  end;

  //关闭注册表
  Reg_ini.Free;
end;

procedure Tf_main.Init_Window();  //调整窗口
begin
  //计算相对宽度、高度平均值
  Width_av:=Book_Width_v/Book_Width;
  Height_av:=Book_Height_v/Book_Height;

  //计算翻页变量
  Page_Move_Width_v:=trunc(Width_av*Page_Move_Width);
  Page_Move_Height_v:=Book_Height_v;
  Page_Next_Left_v:=trunc(Width_av*Page_Next_Left);

  //计算按钮变量
  //Book_Button_Width_v:=Page_Move_Width_v;
  //if Book_Button_Width_v<13 then
  Book_Button_Width_v:=13;

  //调整窗口
  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;       //写标志:允许改变窗口大小

  //调整底图大小
  Book_Image.Width:=Book_Width_v;
  Book_Image.Height:=Book_Height_v;

  //调整翻页
  Page_Prev.Width:=Page_Move_Width_v;
  Page_Prev.Height:=Page_Move_Height_v;

  Page_Next.Width:=Page_Move_Width_v;
  Page_Next.Height:=Page_Move_Height_v;
  Page_Next.Left:=Page_Next_Left_v;

  //调整按钮
  Book_MinSize.Left:=Book_Image.Width-Book_Button_Width_v;
  Book_MinSize.Top:=0;
  Book_MinSize.Width:=Book_Button_Width_v;
  Book_MinSize.Height:=Book_Button_Width_v;

  Book_Move.Left:=Book_Image.Width-Book_Button_Width_v;
  Book_Move.Top:=Book_Image.Height-2*Book_Button_Width_v-1;
  Book_Move.Width:=Book_Button_Width_v;
  Book_Move.Height:=Book_Button_Width_v;

  Book_Resize.Left:=Book_Image.Width-Book_Button_Width_v;
  Book_Resize.Top:=Book_Image.Height-Book_Button_Width_v;
  Book_Resize.Width:=Book_Button_Width_v;
  Book_Resize.Height:=Book_Button_Width_v;

  //调整时间显示框
  Time_Panel.Left:=1;
  Time_Panel.Top:=1;
end;

procedure Tf_main.Init_Page();
begin
  //判断打开文件名是否正确
  if filename='' then
  begin  //无文件名,则打开说明文件
       filename:='说明文件';                //写说明文件的文件名

       TextRead_Bak[1]:=readme.Text;        //调整原始文本框
       TextRead_Ready[1]:=TextRead_Bak[1];  //调整处理文本框

       CountTextRead:=1;                    //总文本框数写1
       CurrentTextRead:=1;                  //当前文本框数写1

       //初始化显示信息
       f_mess.compper.Min:=0;
       f_mess.compper.Max:=CountTextRead;
       f_mess.compper.Position:=f_mess.compper.Min;

       //处理文本框
       Init_BIG5;  //BIG5码处理
       Init_html;  //html处理
       Init_Chap;  //智能分段

       //关闭显示信息
       f_mess.Close;
       Application.ProcessMessages;
  end;

  //显示信息
  f_mess.ShowMess.Caption:='初始化书本';
  f_mess.compper.Position:=f_mess.compper.Min;
  f_mess.show;
  Application.ProcessMessages;

  //调整字体

⌨️ 快捷键说明

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