Modal form hides behind other window
Modal form hides behind other window
(OP)
Hi.
Sometimes, when I show a Form with ShowModal, the form hides behind the mainform. Especially when I change between applications with Alt-Tab.
This problem is very common when showing modal dialogs from an .DLL file.
Has anyone solved this problem? I've read a lot regarding this problem, but noone has presented a solution...
Sometimes, when I show a Form with ShowModal, the form hides behind the mainform. Especially when I change between applications with Alt-Tab.
This problem is very common when showing modal dialogs from an .DLL file.
Has anyone solved this problem? I've read a lot regarding this problem, but noone has presented a solution...
//Nordlund
RE: Modal form hides behind other window
In the main app, keep a note of the modal form's handle. In some OnAppShow event post (not send) a message to the
modal form, like:
PostMessage(ModalFormHandle,WM_MYSHOW,0,0);
In the modal form handle the message like:
procedure WMMYSHOW(var Message: TMessage); message WM_MYSHOW;
procedure TModalForm.WMMYSHOW(var Message: TMessage);
begin
Show;
if(Owner is TApplication)then begin
(Owner as TApplication).BringToFront;
BringToFront;
end;
If in doubt add Application.ProcessMessages anywhere and everywhere!
You will need to tinker with the above as it only conveys the concept. It is extracted from code I used in a similar situation to yours with medium success.
Good luck
Simon
RE: Modal form hides behind other window
I've also noticed that my GExperts (which I love) "Clean Directories" process sometimes leaves the finished message in the back.
Switching back and forth via the taskbar tends to bring the hidden window to the front as well, not that you should try to communicate that to a large user base as a solution.
Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole