I have some code, which calls the form.ShowDialog(IWin32Window) overload rather than the form.ShowDialog() one, but which passes in the current active window as the parameter.
Using the other overload seems to leave the behaviour intact. Is it safe to switch to the simpler overload? When would I want to pass in the IWin32Window parameter?
The
IWin32Windowparameter is for specifying the owner of the dialog. In this case it’s an interface so that you can have non-managed windows (those from a COM object you’re using, for example) as the dialog’s owner.I have to disagree with the users here who say that you shouldn’t specify an owner. In fact, it’s always advisable to specify an owner for a form when possible. While dialogs may not be as important as non-modal forms, getting into the habit of specifying an owner is always a good idea.