Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Modal form hides behind other window

Modal form hides behind other window

Modal form hides behind other window

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...


RE: Modal form hides behind other window

You could try this.

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:


In the modal form handle the message like:

procedure WMMYSHOW(var Message: TMessage); message WM_MYSHOW;

procedure TModalForm.WMMYSHOW(var Message: TMessage);

  if(Owner is TApplication)then begin
    (Owner as TApplication).BringToFront;


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

RE: Modal form hides behind other window

In our current WinXP environment, I have noticed this as well.  We have a custom message dialog that occasionally would get stuck behind other windows, giving the impression that the program is frozen.  This dialog happens to have a timer on it to allow some messages to disappear without user intervention, so we dropped some code to bring the window to the front in there (not an especially elegant solution).  

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.

"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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close