📄 pubunit.pas
字号:
var IniFile : TIniFile ;
Count,i : Integer ;
begin
if FileExists(SysPath + 'SongList.ini') then DeleteFile(SysPath + 'SongList.ini');
Count := Length(Pub_SongListArr);
IniFile := TIniFile.Create(SysPath+'SongList.ini');
IniFile.WriteInteger('Song Index','Index',P_SongIndex);
IniFile.WriteInteger('Song Count','Count',Count);
for i := Low(Pub_SongListArr) to High(Pub_SongListArr) do
begin
IniFile.WriteString('Song'+IntToStr(i),'SongName',Pub_SongListArr[i].SongName);
IniFile.WriteString('Song'+IntToStr(i),'FileName',Pub_SongListArr[i].FileName);
end;
IniFile.Free ;
end;
procedure LoadSongList();//导入歌曲列表
var IniFile : TIniFile ;
Count,i : Integer ;
SongName,FileName : String;
begin
IniFile := TIniFile.Create(SysPath+'SongList.ini');
Count := IniFile.ReadInteger('Song Count','Count',0);
P_SongIndex := IniFile.ReadInteger('Song Index','Index',0);
for i := 0 to Count - 1 do
begin
SongName := IniFile.ReadString('Song'+IntToStr(i),'SongName','');
FileName := IniFile.ReadString('Song'+IntToStr(i),'FileName','');
if ((SongName <> '') and (FileExists(FileName))) then
begin
SetLength(Pub_SongListArr,Length(Pub_SongListArr)+1);
Pub_SongListArr[High(Pub_SongListArr)].SongName := SongName ;
Pub_SongListArr[High(Pub_SongListArr)].FileName := FileName ;
end;
end;
IniFile.Free ;
end;
procedure WriteIni ;
var
IniFile : TIniFile ;
FileName,ExtName : String;
begin
ExtName := ExtractFileExt(Application.ExeName);
FileName := AnsiReplaceStr(ExtractFileName(Application.ExeName),ExtName,'')+'.ini';
IniFile := TIniFile.Create(SysPath + FileName);
{相册设置}
IniFile.WriteBool('Photo Set','RandomStyle',P_RandomStyle);
IniFile.WriteBool('Photo Set','TurnStyle',P_TurnStyle);
IniFile.WriteInteger('Photo Set','StyleValue',P_StyleValue);
IniFile.WriteBool('Photo Set','ManualStyle',P_ManualStyle);
IniFile.WriteBool('Photo Set','AutoStyle',P_AutoStyle);
IniFile.WriteBool('Photo Set','ClearOldImage',P_ClearOldImage);
IniFile.WriteBool('Photo Set','Threaded',P_Threaded);
IniFile.WriteInteger('Photo Set','ShowPause',P_ShowPause);
IniFile.WriteInteger('Photo Set','StepValue',P_StepValue);
IniFile.WriteInteger('Photo Set','P_DelayValue',P_DelayValue);
IniFile.WriteString('Photo Set','PicPath',PicPath);
{系统设置}
IniFile.WriteString('System','Application Name',P_AppName);
IniFile.WriteBool('System','Debug Mode',P_DebugFlag);
{界面设置}
IniFile.WriteInteger('Interface','Interface Value',P_InterFace);
IniFile.WriteInteger('Interface','Splash Window Delay time',P_SplashDelay);
IniFile.WriteString('Interface','Interface Picture',P_PicFileName);
{序列号设置}
IniFile.WriteString('Serial','prefix',P_BmPrefix);
IniFile.WriteInteger('Serial','Digital Sf',P_BmDigSf);
IniFile.WriteString('Serial','Space',P_BmSpace);
IniFile.WriteString('Serial','Year',P_BmYear);
IniFile.WriteString('Serial','Month',P_BmMonth);
IniFile.WriteInteger('Serial','Digital Xlh',P_BmDigXlh);
IniFile.WriteInteger('Serial','Xlh',P_Xlh);
IniFile.Free ;
end;
procedure ReadIni ;
var
IniFile : TIniFile ;
FileName,ExtName : String;
begin
ExtName := ExtractFileExt(Application.ExeName);
FileName := AnsiReplaceStr(ExtractFileName(Application.ExeName),ExtName,'')+'.ini';
IniFile := TIniFile.Create(SysPath + FileName);
{相册设置}
P_RandomStyle := IniFile.ReadBool('Photo Set','RandomStyle',true);
P_TurnStyle := IniFile.ReadBool('Photo Set','TurnStyle',false);
P_StyleValue := IniFile.ReadInteger('Photo Set','StyleValue',1);
P_ManualStyle := IniFile.ReadBool('Photo Set','ManualStyle',false);
P_AutoStyle := IniFile.ReadBool('Photo Set','AutoStyle',true);
P_ClearOldImage := IniFile.ReadBool('Photo Set','ClearOldImage',false);
P_Threaded := IniFile.ReadBool('Photo Set','Threaded',true);
P_ShowPause := IniFile.ReadInteger('Photo Set','ShowPause',2);
P_StepValue := IniFile.ReadInteger('Photo Set','StepValue',4);
P_DelayValue := IniFile.ReadInteger('Photo Set','P_DelayValue',40);
PicPath := IniFile.ReadString('Photo Set','PicPath',SysPath);
{系统设置}
P_AppName := IniFile.ReadString('System','Application Name','Angel销售帐目管理系统');
P_DebugFlag := IniFile.ReadBool('System','Debug Mode',False);
{界面设置}
P_InterFace := IniFile.ReadInteger('Interface','Interface Value',Ord(WinXP));
P_SplashDelay := IniFile.ReadInteger('Interface','Splash Window Delay time',2);
P_PicFileName := IniFile.ReadString('Interface','Interface Picture','');
{序列号设置}
P_BmPrefix := IniFile.ReadString('Serial','prefix','SC/XS_');
P_BmDigSf := IniFile.ReadInteger('Serial','Digital Sf',4);
P_BmSpace := IniFile.ReadString('Serial','Space','_');
P_BmYear := IniFile.ReadString('Serial','Year',FormatDateTime('YY',Date));
P_BmMonth := IniFile.ReadString('Serial','Month',FormatDateTime('MM',Date));
P_BmDigXlh := IniFile.ReadInteger('Serial','Digital Xlh',4);
P_Xlh := IniFile.ReadInteger('Serial','Xlh',0);
IniFile.Free ;
end;
//以下函数可以找到一个控件是否有某个属性
function FindProperty(AClass: TObject; sPropertyName: String): Boolean;
var
PropList: PPropList;
ClassTypeInfo: PTypeInfo;
ClassTypeData: PTypeData;
i: integer;
begin
Result := False;
ClassTypeInfo := aClass.ClassType.ClassInfo;
ClassTypeData := GetTypeData(ClassTypeInfo);
if ClassTypeData.PropCount <> 0 then
begin
GetMem(PropList,SizeOf(PPropInfo)*ClassTypeData.PropCount);
try
GetPropInfos(AClass.ClassInfo,PropList);
for i := 0 to ClassTypeData.PropCount - 1 do
if (PropList[i]^.PropType^.Kind <> tkMethod)
and (UpperCase(PropList[i]^.Name) = UpperCase(sPropertyName)) then
begin
Result := True;
Break;
end;
finally
FreeMem(PropList, SizeOf(PPropInfo) * ClassTypeData.PropCount);
end;
end;
end;
//======改变窗口的显示风格
Procedure ChangeInterface(MyForm : TForm; MysuiForm : TSuiForm);
var i,Count : integer ;
begin
MysuiForm.UIStyleAutoUpdateSub := false ;
case P_Interface of
Ord(BlueGlass) : MysuiForm.UIStyle := BlueGlass ;
Ord(DeepBlue) : MysuiForm.UIStyle := DeepBlue ;
Ord(Protein) : MysuiForm.UIStyle := Protein ;
Ord(MacOS) : MysuiForm.UIStyle := MacOS ;
Ord(WinXP) : MysuiForm.UIStyle := WinXP ;
end;
Count := MyForm.ComponentCount ;
for i := 0 to Count - 1 do
begin
if FindProperty(MyForm.Components[i],'UIStyle') then
SetPropValue(MyForm.Components[i],'UIStyle',MysuiForm.UIStyle);
{ if FindProperty(MyForm.Components[i],'Hint') then
if FindProperty(MyForm.Components[i],'Caption') then
ShowBalloonTip(TWinControl(MyForm.Components[i]),1,PChar(TCustomForm(MyForm.Components[i]).Caption),PWideChar(TCustomForm(MyForm.Components[i]).Hint))
else
ShowBalloonTip(TWinControl(MyForm.Components[i]),1,PChar('系统提示'),PWideChar(TCustomForm(MyForm.Components[i]).Hint));}
end;
MysuiForm.Update ;
MysuiForm.Refresh ;
MyForm.Refresh ;
end;
//========显示BALLOON窗口提示
procedure ShowBalloonTip(Control: TWinControl; Icon: integer; Title: pchar; Text : PWideChar);
const
TOOLTIPS_CLASS = 'tooltips_class32';
TTS_ALWAYSTIP = $01;
TTS_NOPREFIX = $02;
TTS_BALLOON = $40;
TTF_SUBCLASS = $0010;
TTF_TRANSPARENT = $0100;
TTF_CENTERTIP = $0002;
TTM_ADDTOOL = $0400 + 50;
TTM_SETTITLE = (WM_USER + 32);
ICC_WIN95_CLASSES = $000000FF;
type
TOOLINFO = packed record
cbSize: integer;
uFlags: integer;
hwnd: THandle;
uId: integer;
rect: TRect;
hinst: THandle;
lpszText: PWideChar;
lParam: integer;
end;
var
hWndTip: THandle;
ti: TOOLINFO;
hWnd: THandle;
begin
hWnd := Control.Handle;
hWndTip := CreateWindow(TOOLTIPS_CLASS, nil,
WS_POPUP or TTS_NOPREFIX or TTS_BALLOON or TTS_ALWAYSTIP,
0, 0, 0, 0, hWnd, 0, HInstance, nil);
if hWndTip <> 0 then
begin
SetWindowPos(hWndTip, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
ti.cbSize := SizeOf(ti);
ti.uFlags := TTF_CENTERTIP or TTF_TRANSPARENT or TTF_SUBCLASS;
ti.hwnd := hWnd;
ti.lpszText := Text;
Windows.GetClientRect(hWnd, ti.rect);
SendMessage(hWndTip, TTM_ADDTOOL, 1, integer(@ti));
SendMessage(hWndTip, TTM_SETTITLE, Icon mod 4, Integer(Title));
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -