I’m writing a Windows shell extension in C# using EZShellExtensions.NET.
I contribute a context menu that shows dialogs.
Suppose that I show an Explorer window (A). Then I use the context menu to show non modal window (B).
In Windows XP and Windows Vista, when I close A, B is closed (I want this behavior). However, in Windows 7, when I close A, B is not closed but it doesn’t respond to events. My questions are:
- Do you know why Windows 7 manage the showed form as a child form?
- Is there a way to maintain the message loop if I close A?
EDIT: If I set A as owner of B, when I close A, B is also closed. But it creates a new issue. B is always over A.
Finally I have implemented it in the following way. The dialog is shown using
ShowDialog()but is launched (and created in a thread).ShowDialog()implements its own message loop, so as the form is launched in a thread, the main form respond to events, and also you can close the main form and the child form still respond to events. This is very useful for a ShellExtension application.Remember dispose all on your form, in order to free the thread, and also the shell extension thread (each shell extension window and childs are executed in a thread).
The following code fixed my issue: