Open new forms BEHIND the active form

  • Thread starter Thread starter Squirrel
  • Start date Start date
S

Squirrel

Hi,

I'm developing a messenger-style application, and everytime a new chatter
comes up, a new window should be opened. Of course, this window should not
get the focus, so I tried ShowWindow API with the SW_SHOWNOACTIVATE flag.
Now the problem is that the new window, although not getting focus, still
appears IN FRONT of the active window where the user is typing, and that's
very annoying of course. What I want is that new windows just appear in the
background, behind the active chat window.

How to accomplish this?

Thanks a lot!
Frederic
 
Hi,

Try using SetWindowPos; you can use the HWND_BOTTOM flag to put the window
at the bottom of the Z-order (below other windows) as follows:

SetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE |
SWP_NOMOVE);

That should work but do take a look at the documentation for SetWindowPos in
case you require the effects provided by any other flags. You probably need
SWP_NOOWNERZORDER as well if your message windows are owned by one that is
likely to be active when the message appears.


Jonathan Holmes
 
Back
Top