I am not sure when Delphi creates the main form’s child components.
In my TMainForm.FormCreate() I am invoking TIdTCPClient.Connect() and TIdTCPClient.SendCmd(). My program shows up in the Windows TAsk manager, but I don’t see the GUI. However, if I disconnect the Ethernet cable & start the program, the GUI appears.
I am guessing this is because I am trying to invoke methods of a child componenet of the main form in the main form’s FormCraete() method.
Oops, I forgot to say – the TIdTCPClient is placed on the form at design time, it is not created dynamically at runtime.
Any comment? Thanks in advance
The problem is that Indy is blocking, and therefore stops the
Createfrom 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
OnCreateevent, that will delay it until the form has been displayed: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.