This article was originally sent to UESTC a network affectionate BBS Delphi version
Weck 2002-5-29 Midas remote login window is too simple, can not allow users to choose the address of the server to connect to, but you can modify this login window for your own style, of course, can therefore someone else's login password record Oh 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 = '/ Software / Pivot / Wages / 1.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 Utes Utmain; {$ r * .dfm} Procedure Tremotelo gin.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: = 'remote login'; 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. The most critical sentence is: Initialization RemoteLogindialogproc: = gxremotelogindialog;