Activating Modal Windows after switching to an application
We have a C# application w开发者_JAVA百科hich contains both modal and non-modal windows. It is possible for a user to have several non-modal windows open and open a modal window from one of these.
If the user switches to another application and then switches back to ours by clicking one of the non-modal windows (other than the one which opened the modal window) in the Task Bar, the non-modal window becomes activated but does not accept input because the modal window is open, but is behind other windows.
How can we ensure that no matter which of our windows the user switches back to, the one which is modal is the one which is actually activated? This is the behaviour exhibited by Microsoft Outlook, for example.
Any assistance would be appreciated.
Its certainly possible, but is really annoying to maintain. I regularly work on an application which mixes modal and non-modal windows. This is my strategy (which isn't 100% full-proof)
- Set the modal windows TOPMOST when possible.
- When certain actions are detected (like pressing windows-d button), you have to manually set the window back to topmost. I dont know why the windows go to the back, but the behavior is not consistent between windows XP, vista, 2003, etc.
Its really annoying maintaining the code that rearranges the windows. I would urge you to try to not mix modal and non-modal windows.
Edit
I forgot to mention that i use WTL and alot of native win32 functions. I also try to create windows which have parent / child relationship so that keyboard and mouse messages get REFLECTED as much as possible to the child windows.
精彩评论