Showing dynamically created form (Lazarus/Linux) lazarus / 62-General ---------------------------------------------------------------------- odvesims · 2015-08-18 13:50 Hey There! Im my application I send request to a server via socket. While the whole socket request/receiving process is taking place I show a dynamically created form that essentially blocks the UI and shows a message telling the user which action is taking place. It closes after the socket's received an answer or after it's timed out. This works perfectly under Windows, however i cant get it to work on Unix systems (Ubuntu version 10). The UI simply blocks but the form is not shown. It shows if I, for instance, put a ShowMessage in between the form "Show" method and the "Close" method. Anyone knows why is this happening and what'd be the way to fix it.. Anyone thinking of a different approach (sure there'd be a "cleaner" way to do it, perhaps using threads? No clue there though...). Thanks in advance, Oscar ---------------------------------------------------------------------- engkin · 2015-08-18 15:04 Show some code. ---------------------------------------------------------------------- odvesims · 2015-08-18 15:09 Hey Engkin It's simple, i create the Form using the following DialogForm:= TForm.Create(Application); DialogForm.Position:= TPosition.poMainFormCenter; DialogForm.SetBounds(100, 100, 254, 116); DialogForm.Caption:= 'Please, wait...'; DialogForm.AlphaBlendValue := 230; // 0..255 DialogForm.AlphaBlend := True; DialogForm.BorderStyle:= TFormBorderStyle.bsDialog; Then i use the DialogForm.Show command to make the TForm visible. But it's not working under UNIX systems. ---------------------------------------------------------------------- eny · 2015-08-18 15:15 Maybe adding 'Application.ProcessMessages' right after the Show helps. ---------------------------------------------------------------------- garlar27 · 2015-08-18 15:18 AFAIK the form would be blocked on Windows too. To fix that put a TTimer on your form and set the Interval to 500 ms or 1000 ms, and set Enabled to true. In the OnTimer event put this code (in case you use form disigner): Code: [Select]Application.ProcessMessages Add this to your code: 1- Add this method to your class Code: [Select]procedure OnTimerEvent(Sender: TObject); procedure TMyClass.OnTimerEvent(Sender: TObject); begin   Application.ProcessMessages end; 2- Add the followin code to your function: Code: [Select]var   ....   MyTimer: TTimer; begin   DialogForm:= TForm.Create(Application);   DialogForm.Position:= TPosition.poMainFormCenter;   DialogForm.SetBounds(100, 100, 254, 116);   DialogForm.Caption:= 'Please, wait...';   DialogForm.AlphaBlendValue := 230; // 0..255   DialogForm.AlphaBlend := True;   DialogForm.BorderStyle:= TFormBorderStyle.bsDialog;   MyTimer := TTimer.Create(DialogForm);   MyTimer.Interval := 500;   MyTimer.OnTimer := @OnTimerEvent;   MyTimer.Enabled := true;   // end; ---------------------------------------------------------------------- engkin · 2015-08-18 15:52 From TApplication.CreateForm source code: Code: [Select]...     if AForm.FormStyle = fsSplash then     begin       // show the splash form and handle the paint message       AForm.Show;       AForm.Invalidate;       ProcessMessages;     end; ... I suggest you do that same: Code: [Select]...   DialogForm.Show   DialogForm.Invalidate;   Application.ProcessMessages;  //<--- edit: correction ... Similar to solutions presented by eny and garlar27. Another possibility is to use QueueAsyncCall for the socket process you have after DialogForm.Show. ---------------------------------------------------------------------- odvesims · 2015-08-18 17:36 Quote from: eny on August 18, 2015, 05:15:00 pmMaybe adding 'Application.ProcessMessages' right after the Show helps. This did the trick!! Thank you so much!!! ^_^