The problem is that Indy is blocking, and therefore stops the Create
from continuing until the connection is made or times out.
You can fix this by using a custom message that you post to your form in the OnCreate
event, that will delay it until the form has been displayed:
const
UM_DOCONNECTION = WM_USER + 1;
type
TForm1=class(TForm)
...
private
procedure UmDoConnection(var Msg: TMessage); message UM_DOCONNECTION;
...
end;
implementation
procedure TForm1.FormCreate(Sender: TObject);
begin
PostMessage(Handle, UM_DOCONNECTION, 0, 0);
// Other stuff
end;
procedure TForm1.UmDoConnection(var Msg: TMessage);
begin
IdTCPClient.Connect;
IdTCPClient.SendCmd(...);
end;
The best way, of course, would be to move your Indy stuff into it's own thread so it has no connection to the main thread.