I would like to have a KeyPreview functionality within Frames, I mean, that when the input (say, one of the controls of the frame is selected, or the mouse is inside) is in a frame (which would have several panels and other controls) then the keys pressed by the user are first processed by the frame.
Is there a way to do this? I haven't found a property similar to KeyPreview in TFrame.
I'm using version XE5 of RAD Studio, altough I mostly work with C++Builder.
Thanks to my recent "When does a ShortCut fire"-investigation, I have worked out a stand alone solution for your Frame.
In short: all key messages enter in
TWinControl.CNKeyDwonof the active control. That method callsTWinControl.IsMenuKeywhich traverses all parents while determining whether the message is a ShortCut. Is does so by calling itsGetPopupMenu.IsShortCutmethod. I have overridden the Frame'sGetPopupMenumethod by creating one if it is not present. Note that at all time you still can add a PopupMenu to the Frame yourself. By subclassingTPopupMenuand overriding theIsShortCutmethod, the Frame'sKeyDownmethod is called, which serves as the KeyPreview functionality you require. (I could also have assigned the OnKeyDdown event handler).