定制远程登陆窗口

本文最初发于UESTC一网深情bbs delphi版

weck
2002-5-29
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='/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
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;
--

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zouguangxian

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值