views:

467

answers:

2

My C# Winforms app has an always-on-top modeless find dialog. Since the user has access to the parent window while the modeless find dialog is open they can choose to open a modal dialog as well. Since the modeless dialog is always-on-top it obscures the modal dialog, but it is not possible for the user to close the modeless dialog at this point since the modal dialog locks out user interaction to all other windows.

Currently I'm working around this by manually adding code to close the modeless find dialog before opening any modal window, I'm wondering if there is a better solution?

A: 

How about making the modeless dialog not-always-on-top before invoking modal dialogs, then restoring it?

modeless.TopMost = false;
// show modal dialog here
modeless.TopMost = true;
Vinay Sajip
A: 

Does the find dialog need to be always on top? If the purpose just is to have it floating above the main form, isn't it sufficiant to set the main form as parent to the find dialog? Then it will always be in front without have to be always-on-top.

Otherwise I'd make the find dialog listen to what happens in the app and take steps accordingly. (This can be solved in numerous ways, from events to a commong base form for all forms in the app to a CBT-hook that listens system-wide for window activation/deactivation.)

danbystrom