程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> 定制遠程登陸窗口

定制遠程登陸窗口

編輯:Delphi
         Midas的遠程登陸窗口太簡單了,不能讓用戶選擇要連接的服務器的地址
  不過好在 通過以下的方法你可以修改這個登陸窗口為你自己非常喜歡
  的風格,當然也因此可以記錄下別人的登陸密碼哦
  unit utLogIn;
  interface
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   
    Dialogs, ExtCtrls, StdCtrls, dxCntner, dxEditor, dxExEdtr, dxEdLib,Registr
  y,SConnect,DB;
  const
    Software='SoftwarePivotWages1.0';
  type
    TRemoteLogin = class(TForm)
      Panel1: TPanel;
      Label1: TLabel;
      Label2: TLabel;
      Label3: TLabel;
      Panel2: TPanel;
      Bevel2: TBevel;
      Bevel1: TBevel;
      edtUserName: TdxEdit;
      edtPassWord: TdxEdit;
      btnOk: TButton;
      btnCancel: TButton;
      cbxServerIP: TdxPickEdit;
    private
      { Private declarations }
    protected
      FConnection:TSocketConnection;
      procedure SaveOptions;
      procedure LoadOptions;
    public
      { Public declarations }
    end;
  var
    RemoteLogin: TRemoteLogin;
  function gxRemoteLoginDialog(var AUserName, APassWord: string): Boolean;
  implementation
  uses utMain;
  {$R *.dfm}
  procedure TRemoteLogin.LoadOptions;
  var
    reg:TRegistry;
  begin
    //Load the Options
    reg:=TRegistry.Create;
    try
      Reg.RootKey := HKEY_LOCAL_MacHINE;
      if Reg.OpenKey(Software, True) then
     begin
        cbxServerIP.Items.CommaText:=Reg.ReadString('Server');
        Reg.CloseKey;
      end;
    finally
      Reg.Free;
      inherited;
    end;
  end;
  procedure TRemoteLogin.SaveOptions;
  var
    reg:TRegistry;
  begin
    //Load the Saved Options
    if (cbxServerIP.Items.IndexOf(cbxServerIP.Text)=-1) then
      cbxServerIP.Items.Insert(0,cbxServerIP.Text);
    reg:=TRegistry.Create;
    try
      Reg.RootKey := HKEY_LOCAL_MacHINE;
      if Reg.OpenKey(Software, True) then
     begin
        Reg.WriteString('Server',cbxServerIP.Items.CommaText);
        Reg.CloseKey;
      end;
    finally
      Reg.Free;
      inherited;
    end;
  end;
  function gxRemoteLoginDialog(var AUserName, APassWord: string): Boolean;
  begin
    with TRemoteLogin.Create(Application) do
    try
      Caption := '遠程登錄';
      LoadOptions;
      edtUserName.Text := AUserName;
      Result := False;
      if AUserName = '' then ActiveControl := edtUserName;
      if (   cbxServerIP.Items.Count=0) then
        cbxServerIP.ItemIndex:=-1
      else
        cbxServerIP.ItemIndex:=0;
      if ShowModal = mrOk then
      begin
        AUserName := edtUserName.Text;
        APassword := edtPassWord.Text;
        frmMain.Connection.Host:=cbxServerIp.Text;
        Result := True;
        SaveOptions;
      end;
    finally
      Free;
    end;

  end;
  end.
  最關鍵的一句是:
  initialization
    RemoteLoginDialogProc := gxRemoteLoginDialog;

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved