📄 uset.pas
字号:
unit uset;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, IniFiles;
type
TfrmSet = class(TForm)
gbtitle: TGroupBox;
edtsTopic: TEdit;
bbtnSet: TBitBtn;
gbbg: TGroupBox;
bbtnClose: TBitBtn;
bbtnBgSet: TBitBtn;
bbtnRestore: TBitBtn;
odBg: TOpenDialog;
procedure bbtnSetClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure bbtnBgSetClick(Sender: TObject);
procedure bbtnRestoreClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmSet: TfrmSet;
implementation
uses umain, uglobal;
var
iFile: tinifile;
sPath: string;
{$R *.dfm}
procedure TfrmSet.FormShow(Sender: TObject);
begin
edtsTopic.Text := sTopic;
end;
procedure TfrmSet.bbtnSetClick(Sender: TObject);
begin
if edtsTopic.Text <> '' then
begin
sPath := ExtractFilePath(Application.ExeName);
iFile := TIniFile.Create(sPath + 'perset.ini');
iFile.WriteString('sTopic', 'topic', Trim(edtsTopic.Text));
MessageBox(self.Handle, '主题设置成功!', '提示', mb_IconInformation + mb_Ok);
frmPer.Caption := Trim(edtsTopic.Text);
iFile.Free;
end
else
begin
MessageBox(self.Handle, '请输入系统主题!', '提示', mb_IconInformation + mb_Ok);
edtsTopic.SetFocus;
end;
end;
procedure TfrmSet.bbtnBgSetClick(Sender: TObject);
var
fName, fNameo: string;
begin
if odBg.Execute then
begin
sPath := ExtractFilePath(Application.ExeName);
iFile := TIniFile.Create(sPath + 'perset.ini');
fNameo := iFile.ReadString('sysbg', 'bground', 'main.jpg');
if FileExists(sPath + fNameo) and (fNameo <> 'main.jpg') then
DeleteFile(sPath + fNameo);
fName := ExtractFileName(odbg.FileName);
CopyFile(Pchar(odbg.FileName), pchar(sPath + 'images\' + fName), false);
iFile.WriteString('sysbg', 'bground', 'images\' + fName);
frmPer.imgMain.Picture.LoadFromFile(sPath + 'images\' + fName);
MessageBox(self.Handle, '背景设置成功!', '提示', mb_IconInformation + mb_Ok);
iFile.Free;
end;
end;
procedure TfrmSet.bbtnRestoreClick(Sender: TObject);
var
fName: string;
begin
sPath := ExtractFilePath(Application.ExeName);
iFile := TIniFile.Create(sPath + 'perset.ini');
fName := iFile.ReadString('sysbg', 'bground', '');
if FileExists(sPath + fName) and (fName <> 'main.jpg') then
DeleteFile(sPath + fName);
iFile.WriteString('sysbg', 'bground', 'main.jpg');
frmPer.imgMain.Picture.LoadFromFile(sPath + 'main.jpg');
MessageBox(self.Handle, '背景复原成功!', '提示', mb_IconInformation + mb_Ok);
iFile.Free;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -