Registriert seit: 15. Sep 2005
Ort: Neu-Ulm
111 Beiträge
RAD-Studio 2009 Arc
|
Re: Daten formübergreifend weitergeben
18. Sep 2005, 13:50
Login- Unit:
Delphi-Quellcode:
unit LoginUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TLoginForm = class(TForm)
LoginEdit: TEdit;
PasswordEdit: TEdit;
LoginButton: TButton;
CancelButton: TButton;
procedure LoginButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Login: string;
Password: string;
end;
var
LoginForm: TLoginForm;
implementation
{$R *.dfm}
procedure TLoginForm.LoginButtonClick(Sender: TObject);
begin
Login:=LoginEdit.Text;
Password:=PasswordEdit.Text;
ModalResult:=mrOK;
end;
procedure TLoginForm.CancelButtonClick(Sender: TObject);
begin
ModalResult:=mrCancel;
end;
end.
Hauptprogramm- Unit:
Delphi-Quellcode:
unit MainUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMainForm = class(TForm)
LoginButton: TButton;
procedure LoginButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
uses
LoginUnit;
function CheckLogin(Login, Password: string): boolean;
begin
Result:=false; // <-- hier muss natürlich sinnvoller Code rein!
end;
procedure TMainForm.LoginButtonClick(Sender: TObject);
begin
repeat
if LoginForm.ShowModal = mrCancel then Break;
until CheckLogin(LoginForm.Login, LoginForm.Password);
end;
end.
Mach' etwas idiotensicher und irgendjemand erfindet einen besseren Idioten!
|
|
Zitat
|