frmConfig.pas
上传用户:youjie821
上传日期:2013-01-27
资源大小:459k
文件大小:2k
- unit frmConfig;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ComCtrls, RzTreeVw, ActnList, RzButton, ExtCtrls, RzPanel,
- ImgList, RzTabs, StdCtrls, Mask, RzEdit, RzLabel, IniFiles;
- type
- TMyTreeNode = class(TTreeNode)
- end;
- TConfigForm = class(TForm)
- RzPanel1: TRzPanel;
- RzButton1: TRzButton;
- RzButton2: TRzButton;
- ActionList1: TActionList;
- actOk: TAction;
- actCancel: TAction;
- ImageList1: TImageList;
- RzPanel2: TRzPanel;
- edtServerPort: TRzEdit;
- RzLabel1: TRzLabel;
- procedure actOkExecute(Sender: TObject);
- procedure actCancelExecute(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- procedure ShowConfigForm;
- implementation
- {$R *.dfm}
- procedure ShowConfigForm;
- begin
- with TConfigForm.Create(nil) do
- try
- ShowModal;
- finally
- Free;
- end;
- end;
- procedure TConfigForm.actOkExecute(Sender: TObject);
- begin
- ModalResult:= mrOk;
- end;
- procedure TConfigForm.actCancelExecute(Sender: TObject);
- begin
- ModalResult:= mrCancel;
- end;
- procedure TConfigForm.FormCreate(Sender: TObject);
- var
- Ini: TIniFile;
- begin
- Ini:= TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'main.ini');
- try
- edtServerPort.Text:= IntToStr(Ini.ReadInteger('Server', 'Port', 9901));
- finally
- Ini.Free;
- end;
- end;
- procedure TConfigForm.FormClose(Sender: TObject; var Action: TCloseAction);
- var
- Ini: TIniFile;
- begin
- if ModalResult = mrOk then
- begin
- Ini:= TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'main.ini');
- try
- Ini.WriteInteger('Server', 'Port', StrToInt(edtServerPort.Text));
- finally
- Ini.Free;
- end;
- end;
- end;
- end.