I use Delphi XE6 : I create a TaskBarButton in my TaskBar. This button is linked on an action who make :
TForm2.Create(nil).ShowModal;
The Form2 is showing without focus. And sometimes, with a complex form, the new form appears behind the application and i have to click anywhere for see it.
Why I haven't focus on the new form created by my taskbutton ? (if I click on a simple button, my new form have focus).
Code in my MainForm :
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Unit2, System.Actions, Vcl.ActnList,
System.Win.TaskbarCore, Vcl.Taskbar;
type
TForm1 = class(TForm)
ActionList1: TActionList;
Action1: TAction;
Taskbar1: TTaskbar;
procedure Action1Execute(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Action1Execute(Sender: TObject);
var
FormTest : TForm2;
begin
try
//self.Enabled := False;
FormTest := TForm2.Create(nil);
FormTest.ShowModal;
finally
FormTest.Free;
//self.Enabled := True;
end;
end;
end.
TForm2 is just a new form with component.