If I understand correctly, then your problem is that when the message box appears, your main form is still invisible.
If so, you have two options:
- Do not show your
SubForm
from the SubForm
event of the main form, but later - Do not show message immediately after
ShowModal
returns, but later
For point number 2, you can use a similar approach, as I suggested here , using PostMessage
. So your code will look something like this:
procedure TMainForm.FormShow(Sender:TObject); begin if (SubForm.ShowModal = mrOK) and bOption1 then begin PostMessage(Self.Handle, WM_SHOWMYDIALOG, 0, 0); end; end;
The WM_SHOWMYDIALOG
handler then displays the actual message. This approach may also work for point 1, see ain answer .
PostMessage
sends a message to the message queue of your application, which will be processed after the main form becomes visible.
Heinrich ulbricht
source share