ConnectDlg.pas
上传用户:llfxmlw
上传日期:2009-09-14
资源大小:335k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit ConnectDlg;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   FormSettings, StdCtrls, Buttons, Registry;
  6. type
  7.   TClientConnectForm = class(TForm)
  8.     Label1: TLabel;
  9.     Label2: TLabel;
  10.     PortEdit: TEdit;
  11.     ConnectBut: TBitBtn;
  12.     CancelBut: TBitBtn;
  13.     FormSettings1: TFormSettings;
  14.     ServerCombo: TComboBox;
  15.     Label3: TLabel;
  16.     PassEdit: TEdit;
  17.     StartScreenBox: TCheckBox;
  18.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  19.     procedure FormShow(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.     procedure  LoadCombo;
  23.     procedure  SaveCombo;
  24.   public
  25.     { Public declarations }
  26.   end;
  27. var
  28.   ClientConnectForm: TClientConnectForm;
  29. implementation
  30. {$R *.DFM}
  31. procedure TClientConnectForm.FormClose(Sender: TObject;
  32.   var Action: TCloseAction);
  33. var
  34.    s : string;
  35.    i : integer;
  36. begin
  37.    s := ServerCombo.Text;
  38.    i := ServerCombo.Items.IndexOf(s);
  39.    if i <> -1 then ServerCombo.Items.Delete(i);
  40.    ServerCombo.Items.Insert(0, s);
  41.    while ServerCombo.Items.Count > 8 do
  42.       ServerCombo.Items.Delete(8);
  43.    ServerCombo.Text := s;
  44.    SaveCombo;
  45.    FormSettings1.SaveSettings;
  46. end;
  47. procedure TClientConnectForm.FormShow(Sender: TObject);
  48. begin
  49.    LoadCombo;
  50.    ServerCombo.SetFocus;
  51. end;
  52. procedure TClientConnectForm.LoadCombo;
  53. var
  54.    ini : TRegIniFile;
  55. begin
  56.    ini := TRegIniFile.Create('Software' + Application.Title);
  57.    ServerCombo.Items.CommaText := ini.ReadString('Servers', 'ServerCombo', '');
  58.    ServerCombo.ItemIndex := 0;
  59.    ini.Free;
  60. end;
  61. procedure TClientConnectForm.SaveCombo;
  62. var
  63.    ini : TRegIniFile;
  64. begin
  65.    ini := TRegIniFile.Create('Software' + Application.Title);
  66.    ini.WriteString('Servers', 'ServerCombo', ServerCombo.Items.CommaText);
  67.    ini.Free;
  68. end;
  69. end.