How can I prevent the change of focus when ShowDialog closes?


I'm trying to implement an alt-tab like behaviour for our application. When the user presses ctrl-tab, a form pops up (using ShowDialog); when they press it again, it focuses the next control in the app's main form. When they release ctrl, the form is hidden.

Unfortunately, when that happens, focus is sent to a different control to the one that was focused. How can I prevent focus change when ShowDialog exits?

You could write a custom dialog that accepts the "to" focus control as a property.... then when exiting, you could set the focus to the "to" control.