unit uResourcelessLoginForm;
{$mode objfpc}{$H+}
interface
uses
SysUtils, Forms, Controls, StdCtrls;
type
{ TResourcelessLoginForm }
TResourcelessLoginForm = class(TForm)
private
LoginButton: TButton;
PasswordEdit: TEdit;
PasswordLabel: TLabel;
procedure LoginButtonClick(Sender: TObject);
procedure SetupGUI;
public
constructor Create; reintroduce;
end;
function LoginIsCorrectDlg: Boolean;
implementation
function LoginIsCorrectDlg: Boolean;
var
dlg: TResourcelessLoginForm;
begin
dlg:=TResourcelessLoginForm.Create;
try
Exit(dlg.ShowModal = mrOK);
finally
dlg.Free;
dlg:=Nil;
end;
end;
{ TResourcelessLoginForm }
constructor TResourcelessLoginForm.Create;
begin
inherited CreateNew(Nil);
AutoSize:=True;
Caption:='Login';
Position:=poScreenCenter;
BorderStyle:=bsDialog;
SetupGUI;
end;
procedure TResourcelessLoginForm.LoginButtonClick(Sender: TObject);
begin
if (PasswordEdit.Text = 'LetMeIn') then
ModalResult:=mrOK
else ModalResult:=mrCancel;
end;
procedure TResourcelessLoginForm.SetupGUI;
begin
PasswordLabel:=TLabel.Create(Self);
with PasswordLabel do begin
AnchorSideLeft.Control:=Self;
AnchorSideTop.Control:=Self;
BorderSpacing.Around:=12;
Caption:='Password:';
Parent:=Self;
end;
PasswordEdit:=TEdit.Create(Self);
with PasswordEdit do begin
AnchorSideLeft.Control:=Self;
AnchorSideTop.Control:=PasswordLabel;
AnchorSideTop.Side:=asrBottom;
Width:=150;
BorderSpacing.Around:=12;
EchoMode:=emPassword;
PasswordChar:='*';
TabOrder:=0;
Parent:=Self;
end;
LoginButton:=TButton.Create(Self);
with LoginButton do begin
AnchorSideLeft.Control:=PasswordEdit;
AnchorSideLeft.Side:=asrRight;
AnchorSideTop.Control:=PasswordEdit;
AnchorSideTop.Side:=asrCenter;
AutoSize:=True;
BorderSpacing.Around:=12;
Caption:='LoginButton';
OnClick:=@LoginButtonClick;
TabOrder:=1;
Parent:=Self;
end;
end;
end.