Delphi – TEdit does not show cursor if form created from project by method

  

If I create a Method like below:

function Login : boolean;
begin
with TMyForm.Create(Application) do
Result := ShowModal = mrOk;
end;

in dpr

begin
Application.Initialize;
if Login then
begin
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end
else
Application.Terminate;
end.

cursor on MyForm’s TEdit control does not show but it has focus. But if I call same Login method from elsewhere cursor is view able. Why it’s happening and how to solve it.

Below is my code:

unit Unit16;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Controls.Presentation, FMX.Edit;

type
TMyForm = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;

function Login : boolean;

var
MyForm: TMyForm;

implementation

{$R *.fmx}

function Login : boolean;
begin
with TMyForm.Create(Application) do
begin
Result := Showmodal = mrOk;
end;
end;

end.

and my program code:

program Project14;

uses
System.StartUpCopy,
FMX.Forms,
Unit15 in ‘Unit15.pas’ {Form15} ,
Unit16 in ‘Unit16.pas’ {MyForm};

{$R *.res}

begin
Application.Initialize;
if Login then
begin
Application.CreateForm(TForm15, Form15);
Application.Run;
end
else
Application.Terminate;

end.

Comments are closed.