I created a Delphi 2010 application that displays a modal login form through a function before Application.Initialize. The login form is not my main form. This is my login form code:
unit frmLogin_u;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TfrmLogin = class(TForm)
edtPass: TEdit;
btnLogin: TButton;
procedure btnLoginClick(Sender: TObject);
private
{ Private declarations }
public
class function Execute: Boolean;
end;
var
frmLogin: TfrmLogin;
implementation
{$R *.dfm}
{ TForm2 }
procedure TfrmLogin.btnLoginClick(Sender: TObject);
begin
if edtPass.Text = 'Delphi' then
ModalResult := mrOk
else
MessageDlg('Incorrect password.', mtError, [mbOk], 0);
end;
class function TfrmLogin.Execute: Boolean;
begin
with TfrmLogin.Create(nil) do
try
Result := ShowModal = mrOk;
finally
Free;
end;
end;
end.
And here is my application source code:
program frmLogin_p;
uses
Forms,
frmMain_u in 'frmMain_u.pas' {frmMain},
frmLogin_u in 'frmLogin_u.pas' {frmLogin};
{$R *.res}
begin
if TfrmLogin.Execute then
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TfrmMain, frmMain);
Application.Run;
end;
end.
Here is my problem: when the login form is displayed, even if its frame style is set to bsDialog, when the form is minimized by clicking on the icon of my taskbar, I cannot restore it after clicking on the taskbar icon again. Now I need to close the application through the task manager and open it again, since I have no way to restore or close it while it is minimized.
Can anyone know why this is happening, and what can I do to solve the problem?