Keyboard Hooks and Menu Activation
Posted on 2010-01-09
I have an edit control descended from TCustomPanel. I am using a keyboard hook to process the input (a global variable referencing the currently focused control tells it what to do, if anything, with the input - this is set by the overridden DoEnter and DoExit methods). Everything works as expected until you start dealing with objects outside the parent form.
As a fix for multiple forms, I added a check for Screen.ActiveControl to the hook procedure. I'm not entirely sure how well that works, and there is still a problem with menus / shortcuts. Ignoring the Alt key will allow a menu to activate, but afterwards, the control still gets the input instead of the menu.
I suppose it would be pretty easy to place code elsewhere such as the form of the menu to deal with it, but I want the control to be completely autonomous and not place any such requirements with the user.