?? regunit.pas
字號:
//---------------------------------------------------------------------------
//(R)CopyRight KivenSoft International ,inc 1999
//單元名稱:讀寫注冊表單元
//程序名稱:電子書庫
//作 者:李會文
//開始時間:1999.07.01
//最后修改:1999.07.06
//備注:此單元定義了讀寫注冊表中應用程序各種信息的單元,在應用程序初始時進行
//---------------------------------------------------------------------------
unit RegUnit;
interface
uses
IniFiles, SysUtils, Forms, Graphics, MainUnit;
type
TAppIni=class
private
FileName:string;
public
//數據庫的各類設置
MyLoveFile :string; //我的最愛數據庫名
NearFile :string; //上次關閉時的數據庫名
FileList :array[0..4] of string;//最近打開的5個文件
OpenSrmWithApp :boolean; //SRM文件是否用應用程序打開
LoadNearFile :boolean; //運行時是否裝入上次打開的數據庫
MyLoveVisible :boolean; //菜單上我的最愛是否顯示
FileListVisible :boolean; //最近打開文件列表是否顯示
SaveDbQuery :boolean; //保存數據庫前是否提示
DelRecordQuery :boolean; //刪除記錄前是否提示
//類成員函數
constructor Create;
destructor Destroy;override;
end;
const
csWidth='Width';
csHeight='Height';
csLeft='Left';
csTop='Top';
csState='State';
csVisible='Visible';
csColor='Color';
csFontName='FontName';
csFontSize='FontSize';
csFontColor='FontColor';
csFontStyle='FontStyle';
csReadOnly='Edit';
csWordWrap='WordWrap';
csFileSection='File';
csMyLoveFile='MyLoveFile';
csNearFile='NearFile';
csFileList0='FileList0';
csFileList1='FileList1';
csFileList2='FileList2';
csFileList3='FileList3';
csFileList4='FileList4';
csOpenSrmWithApp='OpenSrmWithApp';
csLoadNearFile='LoadNearFile';
csMyLoveVisible='MyLoveVisible';
csFileListVisible='FileListVisible';
csSaveDbQuery='SaveDbQuery';
csDelRecordQuery='DelRecordQuery';
var
AppIni:TAppIni;
implementation
constructor TAppIni.Create;
var
i,n:integer;
Ini:TIniFile;
pStyles:pointer;
s:string;
begin
//求出應用程序的INI文件名
FileName:=Application.ExeName;
n:=Length(FileName);
FileName[n-2]:='i';
FileName[n-1]:='n';
FileName[n] :='i';
FileName:=LowerCase(FileName);
Ini:=TIniFile.Create(FileName);
with Ini do
begin
//MainFrom Section
with SrmForm do
begin
s:=Name;
SetBounds(ReadInteger(s,csLeft,0),
ReadInteger(s,csTop,0),
ReadInteger(s,csWidth,Width),
ReadInteger(s,csHeight,Height));
WindowState:=TWindowState(ReadInteger(s,csState,integer(WindowState)));
end;
//LeftFrom Section
with SrmForm.LeftForm do
begin
s:=Name;
Width:=ReadInteger(s,csWidth,Width);
Visible:=ReadBool(s,csVisible,Visible);
end;
//TreeView Section
with SrmForm.TreeView do
begin
s:=Name;
Color:=ReadInteger(s,csColor,Color);
with SrmForm.TreeView.Font do
begin
Name:=ReadString(s,csFontName,Name);
Size:=ReadInteger(s,csFontSize,Size);
Color:=ReadInteger(s,csFontColor,Color);
n:=ReadInteger(s,csFontStyle,0);
pStyles:=@n;
Style:=TFontStyles(pStyles^);
end;
end;
//RichEdit Section
with SrmForm.RichEdit do
begin
s:=Name;
Color:=ReadInteger(s,csColor,Color);
with SrmForm.RichEdit.Font do
begin
Name:=ReadString(s,csFontName,Name);
Size:=ReadInteger(s,csFontSize,Size);
Color:=ReadInteger(s,csFontColor,Color);
n:=ReadInteger(s,csFontStyle,0);
pStyles:=@n;
Style:=TFontStyles(pStyles^);
end;
ReadOnly:=ReadBool(s,csReadOnly,ReadOnly);
WordWrap:=ReadBool(s,csWordWrap,WordWrap);
end;
//ToolBar Section
with SrmForm.ControlBar do
begin
s:=Name;
n:=ControlCount-1;
for i:=0 to n do
with SrmForm.ControlBar.Controls[i] do
begin
Left:=ReadInteger(s,Name+csLeft,Left);
Top:=ReadInteger(s,Name+csTop,Top);
end;
end;
//StatusBar Section
with SrmForm.StatusBar do
begin
s:=Name;
Visible:=ReadBool(s,csVisible,Visible);
end;
//ToolBar SpeedButton
with SrmForm do
begin
TitleToolButton.Down:=LeftForm.Visible;
ReadOnlyToolButton.Down:=RichEdit.ReadOnly;
end;
//File Section
MyLoveFile:=ReadString(csFileSection,csMyLoveFile,'');
NearFile:=ReadString(csFileSection,csNearFile,'');
FileList[0]:=ReadString(csFileSection,csFileList0,'');
FileList[1]:=ReadString(csFileSection,csFileList1,'');
FileList[2]:=ReadString(csFileSection,csFileList2,'');
FileList[3]:=ReadString(csFileSection,csFileList3,'');
FileList[4]:=ReadString(csFileSection,csFileList4,'');
OpenSrmWithApp:=ReadBool(csFileSection,csOpenSrmWithApp,true);
LoadNearFile:=ReadBool(csFileSection,csLoadNearFile,true);
MyLoveVisible:=ReadBool(csFileSection,csMyLoveVisible,true);
FileListVisible:=ReadBool(csFileSection,csFileListVisible,true);
SaveDbQuery:=ReadBool(csFileSection,csSaveDbQuery,true);
DelRecordQuery:=ReadBool(csFileSection,csDelRecordQuery,true);
//MainMenu
with SrmForm do
begin
StatusMenuItem.Checked:=StatusBar.Visible;
TitleMenuItem.Checked:=LeftForm.Visible;
ReadOnlyMenuItem.Checked:=RichEdit.ReadOnly;
end;
Ini.Free;
end;
end;
destructor TAppIni.Destroy;
var
i,n:integer;
Ini:TIniFile;
tmpStyles:TFontStyles;
pStyles:pointer;
s:string;
begin
Ini:=TIniFile.Create(FileName);
with Ini do
begin
//MainFrom Section
with SrmForm do
begin
s:=Name;
WriteInteger(s,csState,integer(WindowState));
if WindowState<>wsNormal then //如果不為正常的話,
begin
WriteInteger(s,csWidth,540) ; //設為一個常值
WriteInteger(s,csHeight,411);
WriteInteger(s,csLeft,Screen.Height div 2); //各為桌面的一半!
WriteInteger(s,csTop,Screen.Width div 2)
end
else
begin
WriteInteger(s,csWidth,Width);
WriteInteger(s,csHeight,Height);
WriteInteger(s,csLeft,Left);
WriteInteger(s,csTop,Top);
end;
end;
//LeftFrom Section
with SrmForm.LeftForm do
begin
s:=Name;
WriteInteger(s,csWidth,Width);
WriteBool(s,csVisible,Visible);
end;
//TreeView Section
with SrmForm.TreeView do
begin
s:=Name;
WriteInteger(s,csColor,Color);
with SrmForm.TreeView.Font do
begin
WriteString(s,csFontName,Name);
WriteInteger(s,csFontSize,Size);
WriteInteger(s,csFontColor,Color);
tmpStyles:=Style;
pStyles:=@TmpStyles;
WriteInteger(s,csFontStyle,integer(pStyles^));
end;
end;
//RichEdit Section
with SrmForm.RichEdit do
begin
s:=Name;
WriteInteger(s,csColor,Color);
with SrmForm.RichEdit.Font do
begin
WriteString(s,csFontName,Name);
WriteInteger(s,csFontSize,Size);
WriteInteger(s,csFontColor,Color);
tmpStyles:=Style;
pStyles:=@TmpStyles;
WriteInteger(s,csFontStyle,integer(pStyles^));
end;
WriteBool(s,csReadOnly,ReadOnly);
WriteBool(s,csWordWrap,WordWrap);
end;
//ToolBar Section
with SrmForm.ControlBar do
begin
s:=Name;
n:=ControlCount-1;
for i:=0 to n do
with SrmForm.ControlBar.Controls[i] do
begin
WriteInteger(s,Name+csLeft,Left);
WriteInteger(s,Name+csTop,Top);
end;
end;
//StatusBar Section
with SrmForm.StatusBar do
begin
s:=Name;
WriteBool(s,csVisible,Visible);
end;
//File Section
WriteString(csFileSection,csMyLoveFile,MyLoveFile);
WriteString(csFileSection,csNearFile,NearFile);
WriteString(csFileSection,csFileList0,FileList[0]);
WriteString(csFileSection,csFileList1,FileList[1]);
WriteString(csFileSection,csFileList2,FileList[2]);
WriteString(csFileSection,csFileList3,FileList[3]);
WriteString(csFileSection,csFileList4,FileList[4]);
WriteBool(csFileSection,csOpenSrmWithApp,OpenSrmWithApp);
WriteBool(csFileSection,csLoadNearFile,LoadNearFile);
WriteBool(csFileSection,csMyLoveVisible,MyLoveVisible);
WriteBool(csFileSection,csFileListVisible,FileListVisible);
WriteBool(csFileSection,csSaveDbQuery,SaveDbQuery);
WriteBool(csFileSection,csDelRecordQuery,DelRecordQuery);
end;
Ini.Free;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -