202 lines
5.3 KiB
Plaintext
202 lines
5.3 KiB
Plaintext
unit DConfig;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls;
|
|
|
|
type
|
|
TDlgConfig = class(TForm)
|
|
pgMain: TPageControl;
|
|
tabNormal: TTabSheet;
|
|
GroupBox1: TGroupBox;
|
|
chSaveSize: TCheckBox;
|
|
chSavePosition: TCheckBox;
|
|
chInitHide: TCheckBox;
|
|
GroupBox2: TGroupBox;
|
|
rdCloseQuestion: TRadioButton;
|
|
rdCloseHide: TRadioButton;
|
|
rdCloseExit: TRadioButton;
|
|
btnDefault: TButton;
|
|
btnSave: TButton;
|
|
btnClose: TButton;
|
|
tabHotkey: TTabSheet;
|
|
Label1: TLabel;
|
|
HotKey1: THotKey;
|
|
chStartupExecute: TCheckBox;
|
|
tabPath: TTabSheet;
|
|
Label2: TLabel;
|
|
Label3: TLabel;
|
|
edLogPath: TEdit;
|
|
edDataPath: TEdit;
|
|
btnSelLogPath: TButton;
|
|
btnSelDatapath: TButton;
|
|
procedure btnSaveClick(Sender: TObject);
|
|
procedure btnSelLogPathClick(Sender: TObject);
|
|
procedure btnSelDatapathClick(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
Constructor Create(aOwner: TComponent); override;
|
|
procedure CreateParams(var Params: TCreateParams); override;
|
|
Destructor Destroy; override;
|
|
|
|
procedure UpdateConfig;
|
|
end;
|
|
|
|
var
|
|
DlgConfig: TDlgConfig;
|
|
|
|
implementation
|
|
|
|
uses
|
|
ManagerConfig, Tocsg.Registry, Define, Tocsg.Path, Tocsg.Shell, Tocsg.Trace;
|
|
|
|
{$R *.dfm}
|
|
|
|
Constructor TDlgConfig.Create(aOwner: TComponent);
|
|
begin
|
|
Inherited Create(aOwner);
|
|
|
|
pgMain.ActivePageIndex := 0;
|
|
UpdateConfig;
|
|
end;
|
|
|
|
procedure TDlgConfig.CreateParams(var Params: TCreateParams);
|
|
begin
|
|
// Params.WndParent := 0;
|
|
Inherited;
|
|
end;
|
|
|
|
Destructor TDlgConfig.Destroy;
|
|
begin
|
|
Inherited;
|
|
end;
|
|
|
|
procedure TDlgConfig.btnSelDatapathClick(Sender: TObject);
|
|
var
|
|
sSelectPath: String;
|
|
begin
|
|
// if SelectDirectoryEx('µ¥ÀÌÅÍ ÀúÀå °æ·Î ¼±ÅÃ', edDataPath.Text, sSelectPath) then
|
|
// edDataPath.Text := sSelectPath;
|
|
end;
|
|
|
|
procedure TDlgConfig.btnSelLogPathClick(Sender: TObject);
|
|
var
|
|
sSelectPath: String;
|
|
begin
|
|
// if SelectDirectoryEx('·Î±× °æ·Î ¼±ÅÃ', edLogPath.Text, sSelectPath) then
|
|
// edLogPath.Text := sSelectPath;
|
|
end;
|
|
|
|
procedure TDlgConfig.UpdateConfig;
|
|
begin
|
|
with gCfg do
|
|
begin
|
|
chSaveSize.Checked := FormSizeSave;
|
|
chSavePosition.Checked := FormPosSave;
|
|
chInitHide.Checked := FormInitHide;
|
|
|
|
case CloseBtnEvent of
|
|
cbeQuestion : rdCloseQuestion.Checked := true;
|
|
cbeHide : rdCloseHide.Checked := true;
|
|
cbeExit : rdCloseExit.Checked := true;
|
|
end;
|
|
|
|
chStartupExecute.Checked := StartupExecute;
|
|
|
|
edLogPath.Text := LogPath;
|
|
edDataPath.Text := DataPath;
|
|
end;
|
|
end;
|
|
|
|
procedure TDlgConfig.btnSaveClick(Sender: TObject);
|
|
begin
|
|
// todo : check
|
|
edLogPath.Text := IncludeTrailingBackslash(Trim(edLogPath.Text));
|
|
edDataPath.Text := IncludeTrailingBackslash(Trim(edDataPath.Text));
|
|
|
|
if edLogPath.Text = '' then
|
|
begin
|
|
MessageBox(Handle, '·Î±× ÀúÀå °æ·Î¸¦ ÀÔ·ÂÇØ ÁֽʽÿÀ.', PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
pgMain.ActivePageIndex := 1;
|
|
edLogPath.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if edDataPath.Text = '' then
|
|
begin
|
|
MessageBox(Handle, 'µ¥ÀÌÅÍ ÀúÀå °æ·Î¸¦ ÀÔ·ÂÇØ ÁֽʽÿÀ.', PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
pgMain.ActivePageIndex := 1;
|
|
edDataPath.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if not DirectoryExists(edLogPath.Text) then
|
|
begin
|
|
if MessageBox(Handle, PChar(Format('·Î±× ÀúÀå °æ·Î·Î ¼³Á¤ÇÑ'+#13+#10+'[%s] ´Â '+#13+#10+
|
|
'Á¸ÀçÇÏÁö ¾Ê´Â °æ·ÎÀÔ´Ï´Ù. »ý¼ºÇϽðڽÀ´Ï±î?', [edLogPath.Text])), PChar(Caption), MB_ICONQUESTION or MB_YESNO) = IDNO then exit;
|
|
|
|
if not ForceDirectories(edLogPath.Text) then
|
|
begin
|
|
MessageBox(Handle, PChar(Format('·Î±× ÀúÀå °æ·Î¸¦ »ý¼ºÇÏ´Â Áß ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.'+#13+#10+
|
|
'È®ÀÎ ÈÄ ´Ù½Ã ½ÃµµÇØ ÁֽʽÿÀ.', [edDataPath.Text])), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
if not DirectoryExists(edDataPath.Text) then
|
|
begin
|
|
if MessageBox(Handle, PChar(Format('µ¥ÀÌÅÍ ÀúÀå °æ·Î·Î ¼³Á¤ÇÑ'+#13+#10+'[%s] ´Â '+#13+#10+
|
|
'Á¸ÀçÇÏÁö ¾Ê´Â °æ·ÎÀÔ´Ï´Ù. »ý¼ºÇϽðڽÀ´Ï±î?', [edDataPath.Text])), PChar(Caption), MB_ICONQUESTION or MB_YESNO) = IDNO then exit;
|
|
|
|
if not ForceDirectories(edDataPath.Text) then
|
|
begin
|
|
MessageBox(Handle, '·Î±× ÀúÀå °æ·Î¸¦ »ý¼ºÇÏ´Â Áß ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.'+#13+#10+
|
|
'È®ÀÎ ÈÄ ´Ù½Ã ½ÃµµÇØ ÁֽʽÿÀ.', PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
with gCfg do
|
|
begin
|
|
FormSizeSave := chSaveSize.Checked;
|
|
FormPosSave := chSavePosition.Checked;
|
|
FormInitHide := chInitHide.Checked;
|
|
StartupExecute := chStartupExecute.Checked;
|
|
if StartupExecute then
|
|
begin
|
|
if not ExistsRunAppByHLM(FAMILY_NAME) then
|
|
AddRunAppByHLM(FAMILY_NAME, Format('"%s%s" /exename %s',
|
|
[GetRunExePathDir, APP_STARTUP, APP_EXECUTE]));
|
|
end else
|
|
DeleteRunAppByHLM(FAMILY_NAME);
|
|
|
|
if rdCloseQuestion.Checked then
|
|
CloseBtnEvent := cbeQuestion
|
|
else
|
|
if rdCloseHide.Checked then
|
|
CloseBtnEvent := cbeHide
|
|
else
|
|
if rdCloseExit.Checked then
|
|
CloseBtnEvent := cbeExit;
|
|
|
|
if LogPath <> edLogPath.Text then
|
|
begin
|
|
LogPath := edLogPath.Text;
|
|
// if gTrace <> nil then
|
|
// gTrace. LogPath := LogPath + ExtractFileName(GetCurrentPath) + '.log';
|
|
end;
|
|
|
|
if DataPath <> edDataPath.Text then
|
|
DataPath := edDataPath.Text;
|
|
|
|
SaveConfig;
|
|
end;
|
|
ModalResult := mrOk;
|
|
end;
|
|
|
|
end.
|