德尔福登录表格如何填写?

2026-04-10 19:172阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计483个文字,预计阅读时间需要2分钟。

德尔福登录表格如何填写?

在我Delphi程序中,有一个登录表单,它在创建主表单之前显示。但我面临的问题是,我想在主表单中处理登录检查,这意味着登录表单将用于检查并持续更新主要表格的结构。请阅读以下评论:

在我的Delphi程序中,我有一个登录表单,它在创建主表单之前显示,但我面临的问题是我想登录检查在主表单中处理,这意味着登录表单将使用要检查并继续的主要表格,

请阅读以下评论:

procedure LogInButtonClick(Sender: TObject) ;

这是TLoginForm代码(from delphi.about.com):

unit login; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TLoginForm = class(TForm) LogInButton: TButton; pwdLabel: TLabel; passwordEdit: TEdit; procedure LogInButtonClick(Sender: TObject) ; public class function Execute : boolean; end; implementation {$R *.dfm} class function TLoginForm.Execute: boolean; begin with TLoginForm.Create(nil) do try Result := ShowModal = mrOk; finally Free; end; end; procedure TLoginForm.LogInButtonClick(Sender: TObject) ; begin if passwordEdit.Text = 'delphi' then { Here how it's possible to use : if MainForm.text=passwordEdit.Text then ModalResult := mrOK } ModalResult := mrOK else ModalResult := mrAbort; end; end.

这是主程序初始化流程:

program PasswordApp; uses Forms, main in 'main.pas' {MainForm}, login in 'login.pas' {LoginForm}; {$R *.res} begin if TLoginForm.Execute then begin Application.Initialize; Application.CreateForm(TMainForm, MainForm) ; Application.Run; end else begin Application.MessageBox('You are not authorized to use the application. The password is "delphi".', 'Password Protected Delphi application') ; end; end.

谢谢

如果您需要首先创建主表单,请先创建它:

德尔福登录表格如何填写?

begin Application.Initialize; Application.CreateForm(TMainForm, MainForm);//created, but not shown if TLoginForm.Execute then//now the login form can refer to the main form Application.Run//this shows the main form else Application.MessageBox('....'); end;

这是你提出的问题的直接和天真的答案.更广泛地思考,我鼓励您将登录测试移出主表单.把它放在任何更高级代码需要使用的地方.您目前正在努力的设计具有不健康的耦合.

本文共计483个文字,预计阅读时间需要2分钟。

德尔福登录表格如何填写?

在我Delphi程序中,有一个登录表单,它在创建主表单之前显示。但我面临的问题是,我想在主表单中处理登录检查,这意味着登录表单将用于检查并持续更新主要表格的结构。请阅读以下评论:

在我的Delphi程序中,我有一个登录表单,它在创建主表单之前显示,但我面临的问题是我想登录检查在主表单中处理,这意味着登录表单将使用要检查并继续的主要表格,

请阅读以下评论:

procedure LogInButtonClick(Sender: TObject) ;

这是TLoginForm代码(from delphi.about.com):

unit login; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TLoginForm = class(TForm) LogInButton: TButton; pwdLabel: TLabel; passwordEdit: TEdit; procedure LogInButtonClick(Sender: TObject) ; public class function Execute : boolean; end; implementation {$R *.dfm} class function TLoginForm.Execute: boolean; begin with TLoginForm.Create(nil) do try Result := ShowModal = mrOk; finally Free; end; end; procedure TLoginForm.LogInButtonClick(Sender: TObject) ; begin if passwordEdit.Text = 'delphi' then { Here how it's possible to use : if MainForm.text=passwordEdit.Text then ModalResult := mrOK } ModalResult := mrOK else ModalResult := mrAbort; end; end.

这是主程序初始化流程:

program PasswordApp; uses Forms, main in 'main.pas' {MainForm}, login in 'login.pas' {LoginForm}; {$R *.res} begin if TLoginForm.Execute then begin Application.Initialize; Application.CreateForm(TMainForm, MainForm) ; Application.Run; end else begin Application.MessageBox('You are not authorized to use the application. The password is "delphi".', 'Password Protected Delphi application') ; end; end.

谢谢

如果您需要首先创建主表单,请先创建它:

德尔福登录表格如何填写?

begin Application.Initialize; Application.CreateForm(TMainForm, MainForm);//created, but not shown if TLoginForm.Execute then//now the login form can refer to the main form Application.Run//this shows the main form else Application.MessageBox('....'); end;

这是你提出的问题的直接和天真的答案.更广泛地思考,我鼓励您将登录测试移出主表单.把它放在任何更高级代码需要使用的地方.您目前正在努力的设计具有不健康的耦合.