The scenario is that I have a ‘main app’ and a ‘helper app’. The ‘helper app’ pops up on a keyboard hook, does it’s stuff, then refocuses the main app window. The problem is that if the main app pops up a modal dialog when helper is active, and the helper then refocuses the wrong window, the modal dialog is hidden and the main app appears ‘frozen’.
Any suggestions of strategies to solve this?
It looks like the modal form of the ‘main app’ is not owned by the main app window, otherwise the modal form would stay above the main form at all times. So, possibly, either there’s no
MainFormOnTaskbarproperty for the Delphi version that it was compiled, or it is not set. Then it must be the hidden application window that owns the windows.You can test if the main app window is disabled when closing your ‘helper app’ form (that would be the case if there’s a modal form), and restore the last active popup window that is owned by the hidden application window if it is.
(Don’t forget to include tests for the result of the API functions of course.)