connectdlg.pas

来自「能够监视另一台机子的屏幕」· PAS 代码 · 共 90 行

PAS
90 行
字号
unit ConnectDlg;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  FormSettings, StdCtrls, Buttons, Registry;

type
  TClientConnectForm = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    PortEdit: TEdit;
    ConnectBut: TBitBtn;
    CancelBut: TBitBtn;
    FormSettings1: TFormSettings;
    ServerCombo: TComboBox;
    Label3: TLabel;
    PassEdit: TEdit;
    StartScreenBox: TCheckBox;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
    procedure  LoadCombo;
    procedure  SaveCombo;
  public
    { Public declarations }
  end;

var
  ClientConnectForm: TClientConnectForm;

implementation

{$R *.DFM}

procedure TClientConnectForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
var
   s : string;
   i : integer;
begin
   s := ServerCombo.Text;
   i := ServerCombo.Items.IndexOf(s);
   if i <> -1 then ServerCombo.Items.Delete(i);
   ServerCombo.Items.Insert(0, s);

   while ServerCombo.Items.Count > 8 do
      ServerCombo.Items.Delete(8);

   ServerCombo.Text := s;

   SaveCombo;
   FormSettings1.SaveSettings;
end;

procedure TClientConnectForm.FormShow(Sender: TObject);
begin
   LoadCombo;

   ServerCombo.SetFocus;
end;

procedure TClientConnectForm.LoadCombo;
var
   ini : TRegIniFile;
begin
   ini := TRegIniFile.Create('Software\' + Application.Title);

   ServerCombo.Items.CommaText := ini.ReadString('Servers', 'ServerCombo', '');
   ServerCombo.ItemIndex := 0;

   ini.Free;
end;

procedure TClientConnectForm.SaveCombo;
var
   ini : TRegIniFile;
begin
   ini := TRegIniFile.Create('Software\' + Application.Title);

   ini.WriteString('Servers', 'ServerCombo', ServerCombo.Items.CommaText);

   ini.Free;
end;


end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?