unit Option;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
StdCtrls, Menus, sDialogs, sSkinManager, sButton, sGroupBox,
sCheckBox, sLabel, sComboBox, AppEvnts;
type
TOptionForm = class(TForm)
CancelButton: TsButton;
ApplyButton: TsButton;
OKButton: TsButton;
sGroupBox1: TsGroupBox;
LocationCheckBox: TsCheckBox;
LimitCheckBox: TsCheckBox;
TransparentLabel: TsLabel;
sLabel1: TsLabel;
sLabel2: TsLabel;
InformationLabel: TsLabel;
TransparentComboBox: TsComboBox;
LimitComboBox: TsComboBox;
PropertiesCheckBox: TsCheckBox;
OnTopCheckBox: TsCheckBox;
ApplicationEvents1: TApplicationEvents;
procedure ComboBox1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ComboBox1Exit(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
procedure ApplyButtonClick(Sender: TObject);
procedure OKButtonClick(Sender: TObject);
procedure LimitCheckBoxClick(Sender: TObject);
procedure TransparentComboBoxChange(Sender: TObject);
procedure TransparentComboBoxClick(Sender: TObject);
procedure TransparentComboBoxExit(Sender: TObject);
procedure LocationCheckBoxClick(Sender: TObject);
procedure OnTopCheckBoxClick(Sender: TObject);
procedure PropertiesCheckBoxClick(Sender: TObject);
procedure ApplicationEvents1Exception(Sender: TObject; E: Exception);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
OptionForm: TOptionForm;
expres,abv:string;
tempflag,tempflag2:boolean;
implementation
uses IniFiles, ShellApi, Unit1, ABOUT, Unit3;
{$R *.dfm}
procedure TOptionForm.ApplicationEvents1Exception(Sender: TObject;
E: Exception);
begin
E:=nil;
end;
procedure TOptionForm.ApplyButtonClick(Sender: TObject);
var Ini:TIniFile;flag1,flag2:boolean;
begin
Ini:=TiniFile.Create(extractfilepath(Application.ExeName)+'Options.ini');
//прозрачность окон
expres:=IntToStr(100-round(AlphaBlendValue/2.55));
abv:=IntToStr(round(StrToInt(TransparentComboBox.Text)/2));
if abv<>expres
then begin
Ini.WriteInteger('View','Alpha_Blend_Value_BackUp',AlphaBlendValue);
AlphaBlendValue:=round(255-2.55*(StrToInt(TransparentComboBox.Text)/2));
Ini.WriteInteger('View','Alpha_Blend_Value',AlphaBlendValue);
Form1.AlphaBlendValue:=AlphaBlendValue;
Form3.AlphaBlendValue:=AlphaBlendValue;
AboutBox.AlphaBlendValue:=AlphaBlendValue;
Application.ProcessMessages;
expres:=IntToStr(100-round(AlphaBlendValue/2.55));
end;
//прозрачность окон
//положение окон
if (Ini.ReadBool('View','Windows_Location_Save',false)<>LocationCheckBox.Checked)
then begin
Ini.WriteBool('View','Windows_Location_Save_BackUp',LocationCheckBox.Checked);
Ini.WriteBool('View','Windows_Location_Save',LocationCheckBox.Checked);
end;
if LocationCheckBox.Checked=true then
begin
Ini.WriteInteger('View','Windows_Location_Left',Form1.Left);
Ini.WriteInteger('View','Windows_Location_Top',Form1.Top);
end;
//положение окон
//сохранение настроек выбора режима
tempflag:=Ini.ReadBool('Properties','Properties_Save',false);
if Ini.ReadBool('Properties','Properties_Save',false)<>PropertiesCheckBox.Checked
then if PropertiesCheckBox.Checked=true then begin
Ini.WriteBool('Properties','Properties_Save_BackUp',tempflag);
Ini.WriteBool('Properties','Properties_Save',true);
end
else begin
Ini.WriteBool('Properties','Properties_Save_BackUp',tempflag);
Ini.WriteBool('Properties','Properties_Save',false);
end;
//сохранение настроек выбора режима
//выход окна за пределы
tempflag:=Ini.ReadBool('View','Windows_Move_Limit',false);
if Ini.ReadBool('View','Windows_Move_Location',false)<>LimitCheckBox.Checked
then if LimitCheckBox.Checked=true then begin
Ini.WriteBool('View','Windows_Move_Limit_BackUp',tempflag);
Ini.WriteBool('View','Windows_Move_Limit',true);
LimitComboBox.Enabled:=true;
end
else begin
Ini.WriteBool('View','Windows_Move_Limit_BackUp',tempflag);
Ini.WriteBool('View','Windows_Move_Limit',false);
LimitComboBox.Enabled:=false;
end;
//выход окна за пределы
//всегда поверх
tempflag:=Ini.ReadBool('View','On_Top',false);
if Ini.ReadBool('View','On_Top',false)<>OnTopCheckBox.Checked
then if OnTopCheckBox.Checked=true then begin
Ini.WriteBool('View','On_Top_BackUp',tempflag);
Ini.WriteBool('View','On_Top',true);
Form1.FormStyle:=fsStayOnTop;
end
else begin
Ini.WriteBool('View','On_Top_BackUp',tempflag);
Ini.WriteBool('View','On_Top',false);
Form1.FormStyle:=fsNormal;
end;
//всегда поверх
ApplyButton.Enabled:=false;
CancelButton.Enabled:=true;
end;
procedure TOptionForm.CancelButtonClick(Sender: TObject);
var Ini:TIniFile;
begin
Ini:=TiniFile.Create((extractfilepath(Application.ExeName)+'Options.ini'));
AlphaBlendValue:=Ini.ReadInteger('View','Alpha_Blend_Value_BackUp',255);
TransparentComboBox.Text:=IntToStr(100-round(AlphaBlendValue/2.55));
LimitCheckBox.Enabled:=Ini.ReadBool('View','Windows_Move_Limit_BackUp',tempflag);
TransparentComboBox.Enabled:=LimitCheckBox.Enabled;
LocationCheckBox.Checked:=Ini.ReadBool('View','Windows_Location_Save_BackUp',tempflag2);
OnTopCheckBox.Checked:= Ini.ReadBool('View','On_Top_BackUp',false);
if OnTopCheckBox.Checked=true then Form1.FormStyle:=fsStayOnTop
else Form1.FormStyle:=fsNormal;
ApplyButton.Enabled:=false;
CancelButton.Enabled:=false;
Ini.Free;
end;
procedure TOptionForm.ComboBox1Change(Sender: TObject);
begin
try
if StrToInt(TransparentComboBox.Text)>98 then TransparentComboBox.Text:=IntToStr(98);
except
on EConvertError do
begin
TransparentComboBox.Text:='';
exit;
end;
end;
end;
procedure TOptionForm.ComboBox1Click(Sender: TObject);
begin
if TransparentComboBox.Text<>IntToStr(100-round(AlphaBlendValue/2.55))
then ApplyButton.Enabled:=true
else ApplyButton.Enabled:=false;
end;
procedure TOptionForm.ComboBox1Exit(Sender: TObject);
begin
if StrToInt(TransparentComboBox.Text)>98 then TransparentComboBox.Text:=IntToStr(98);
if TransparentComboBox.Text='' then TransparentComboBox.Text:=expres;
expres:=IntToStr(100-round(AlphaBlendValue/2.55));
abv:=IntToStr(round(StrToInt(TransparentComboBox.Text)/2));
if abv=expres
then ApplyButton.Enabled:=false;
end;
procedure TOptionForm.FormClose(Sender: TObject; var Action: TCloseAction);
var ini:TiniFile;
begin
Ini.Free;
OptionForm.Visible:=false;
Form1.SetFocus;
exit;
end;
procedure TOptionForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
OptionForm.Visible:=false;
Form1.Visible:=true;
Form1.SetFocus;
end;
procedure TOptionForm.FormDestroy(Sender: TObject);
var MainHandle: THandle;
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
MainHandle := OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessID);
SetProcessWorkingSetSize(MainHandle, DWORD(-1), DWORD(-1));
CloseHandle(MainHandle);
end;
end;
procedure TOptionForm.OKButtonClick(Sender: TObject);
var Ini:TIniFile;
temp:integer;
begin
Ini:=TIniFile.Create(extractfilepath(Application.ExeName)+'Options.ini');
try
Ini.WriteInteger('View','Alpha_Blend_Value',AlphaBlendValue);
except
on EConvertError do
begin
temp:=Ini.ReadInteger('View','Alpha_Blend_Value_BackUp',0);
Ini.WriteInteger('View','Alpha_Blend_Value',temp);
exit;
end;
end;
Ini.WriteBool('View','Windows_Move_Limit',tempflag);
Ini.WriteBool('View','Windows_Location_Save',LocationCheckBox.Checked);
Ini.WriteBool('View','On_Top',OnTopCheckBox.Checked);
Ini.Free;
OptionForm.Visible:=false;
Form1.Visible:=true;
Form1.SetFocus;
exit;
end;
procedure TOptionForm.TransparentComboBoxChange(Sender: TObject);
var Ini:TIniFile;
begin
try
if StrToInt(TransparentComboBox.Text)>98 then TransparentComboBox.Text:=IntToStr(98);
except
on EConvertError do
begin
TransparentComboBox.Text:='';
exit;
end;
end;
end;
procedure TOptionForm.TransparentComboBoxExit(Sender: TObject);
begin
try
if StrToInt(TransparentComboBox.Text)>98 then TransparentComboBox.Text:=IntToStr(98);
if TransparentComboBox.Text='' then TransparentComboBox.Text:=expres;
except
on EConvertError do
TransparentComboBox.Text:='0';
end;
expres:=IntToStr(100-round(AlphaBlendValue/2.55));
abv:=IntToStr(round(StrToInt(TransparentComboBox.Text)/2));
if abv=expres
then ApplyButton.Enabled:=false;
end;
end.