Author: Jonas Bilinkevicius
How can I wait until the form is actually painted on screen, before starting the
processing so that I can be sure that any exceptions are displayed after the form
is painted. I've considered a short timer in the OnCreate. Is there a better way
(i.e. catching a Windows message)?
Answer:
Use an custom message:
1 const2 UM_AFTERSHOW = WM_USER + 1001;
3 4 type5 TMyForm = class(TForm)
6 procedure FormShow(Sender: TObject);
7 private8 procedure UMAfterShow(var Msg: TMessage); message UM_AFTERSHOW;
9 end;
10 11 implementation12 13 procedure TMyForm.FormShow(Sender: TObject);
14 begin15 PostMessage(Self.Handle, UM_AFTERSHOW, 0, 0);
16 end;
17 18 procedure TMyForm.UMAfterShow(var Msg: TMessage);
19 begin20 {your code here}21 end;