I open Form2.ShowModal in FormMain. I want the application to show Form2 intact while doing some database access (this is not about the new data to be shown). However, while FormShow is executed, just the outer border and some broken parts are displayed, some broken parts of FormMain show through. It's ugly.
I have not been able to find a way to make Delphi repaint the Form immediately and then doing the time-consuming MyOpenData procedure. After concluding MyOpenData everything is fine.
procedure TForm2.FormShow(Sender: TObject);
begin
Invalidate;
Refresh;
MyOpenData; { needs some seconds of database accesses }
end;
Alternative:
procedure TForm2.FormShow(Sender: TObject);
begin
Invalidate;
Refresh;
SendMessage(Handle, wm_paint, 0, 0);
PostMessage(Handle, wm_OpenMyData, 0, 0); { executes well, but no solution)
end;
This doesn't work either. I thought SendMessage() waits for the message being done. But no Paint is done before MyOpenData. The form always looks broken till the procedures finishes. Besides this, the routines are executed fine. I tried all these commands combined or separately.
What am I missing? Thanks in advance!
How do you start time-consuming routines that need to run when opening a form?
(Delphi XE7 on Windows 7 64 bit)