home *** CD-ROM | disk | FTP | other *** search
- { --------------------------------------------------------------- }
- { Xceed FTP Library - client sample }
- { Copyright (c) 2000 Xceed Software Inc. }
- { }
- { [frmConnect.pas] }
- { }
- { This form contains code for the "Connection Information" }
- { dialog box. }
- { }
- { This file is part of the Xceed FTP Library Sample applications. }
- { The source code in this file is only intended as a supplement }
- { to Xceed FTP Library's documentation, and is provided "as is", }
- { without warranty of any kind, either expressed or implied. }
- { --------------------------------------------------------------- }
-
- unit unConnectInfo;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
-
- type
- TfrmConnect = class(TForm)
- edtHostAddress : TEdit;
- edtUserName : TEdit;
- edtPassword : TEdit;
- edtPort : TEdit;
- lblHostAddress : TLabel;
- lblUserName : TLabel;
- lblPassword : TLabel;
- lblPort : TLabel;
- grpLoginType : TGroupBox;
- optAnonymous : TRadioButton;
- optNormal : TRadioButton;
- btConnect : TButton;
- btCancel : TButton;
-
- procedure FormCreate(Sender: TObject);
- procedure optNormalClick(Sender: TObject);
- procedure optAnonymousClick(Sender: TObject);
- procedure btCancelClick(Sender: TObject);
- procedure btConnectClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Set to true or false depending on if the cancel button was clicked }
- m_bCancelled : boolean;
-
- function GetConnectInfo(var sHostAddress : string; var nPort : integer;
- var sUserName : string; var sPassword : string) : boolean;
- end;
-
- var
- frmConnect : TfrmConnect;
- implementation
-
- {$R *.DFM}
- { ------------------------------------------------------------- }
- procedure TfrmConnect.FormCreate(Sender: TObject);
- begin
- m_bCancelled := false; { Initialize to false (means user clicked Connect button }
- optAnonymous.Checked := true; { By default, we want anonymous to be selected }
- end;
-
- { ------------------------------------------------------------- }
- { If the "normal" option is selected, we will enable the }
- { username and password edit boxes. }
- { ------------------------------------------------------------- }
- procedure TfrmConnect.optNormalClick(Sender: TObject);
- begin
- edtUserName.Enabled := true; { Enable the username edit box }
- edtPassword.Enabled := true; { Enable the password edit box }
-
- edtUserName.Color := $80000009;
- edtPassword.Color := $80000009;
- end;
-
- { ------------------------------------------------------------- }
- { If the "anonymous" option is selected, we will disable the }
- { username and password edit boxes. }
- { ------------------------------------------------------------- }
- procedure TfrmConnect.optAnonymousClick(Sender: TObject);
- begin
- edtUserName.Enabled := false; { Disable the username edit box }
- edtPassword.Enabled := false; { Disable the password edit box }
-
- edtUserName.Color := $8000000F;
- edtPassword.Color := $8000000F;
- end;
-
- { ------------------------------------------------------------- }
- procedure TfrmConnect.btCancelClick(Sender: TObject);
- begin
- m_bCancelled := true; { Set to true if cancel button was clicked }
- Self.Close; { Close the "Connection Information" dialog form }
- end;
-
- { ------------------------------------------------------------- }
- { The following procedure is called by the DoConnect procedure }
- { of our main form. It retreives the information entered in }
- { frmConnect and sends it back to the DoConnect procedure. }
- { ------------------------------------------------------------- }
- function TfrmConnect.GetConnectInfo(var sHostAddress : string;
- var nPort : integer; var sUserName : string;
- var sPassword : string) : boolean;
- begin
- m_bCancelled := false;
- Self.ShowModal;
-
- if not m_bCancelled then
- begin
- sHostAddress := edtHostAddress.Text; { Set the host address }
- nPort := StrToInt(edtPort.Text); { Set port. Default is 21 }
-
- if optAnonymous.Checked then { anonymous }
- begin
- sUserName := 'anonymous';
- sPassword := 'guest';
- end
- else
- begin
- sUserName := edtUserName.Text; { Set the username }
- sPassword := edtPassword.Text; { Set the password }
- end;
- end;
-
- GetConnectInfo := not m_bCancelled;
- end;
-
- { ------------------------------------------------------------- }
- procedure TfrmConnect.btConnectClick(Sender: TObject);
- begin
- m_bCancelled := false;
- Self.Close;
- end;
- end.
-