I've built a custom control that I'm trying to send input to. It will accept mouse input and report MouseDown, MouseMove and MouseUp correctly, but for whatever reason, it won't accept keyboard input. When I click on it, it doesn't receive focus, and any keys I press get interpreted by whatever control had the focus already.
This is probably something really simple. The first place I thought to look was in the ControlStyle property, but the only thing I can see in the helpfile about keyboard input is csNoStdEvents
, which disables it, and my control doesn't have that. So what do I need to do to make it so my control can receive input focus?
A few things to try:
MouseDown
, callWindows.SetFocus(Handle)
. In my experience, the WinAPI functionSetFocus
often works better than the VCL'sSetFocus
method.WM_GETDLGCODE
message, reply withMessage.Result := Message.Result or DLGC_WANTCHARS or DLGC_WANTARROWS or DLGC_WANTTAB or DLGC_WANTALLKEYS
;