I have a WinForm app that has other child forms (not mdi). If the user presses “Esc” the topmost form should be closed even if it doesn’t have the focus.
I can use a keyboard hook to globally catch the Escape but I also need the handle of the form to be closed.
I guess there is a way to do that using Win32 API, but is there a solution using managed code?
Here is one way to get the topmost form that uses Win32 (not very elegant, but it works):