how to set the 'real' focus to a form lazarus / 7-LCL ---------------------------------------------------------------------- Martin V · 2010-05-10 12:05 Hello, I have got a form which has at least one control which can hold the focus (e.g. a tEdit or a tButton). If I use MyForm.SetFocus then the active control inside the form still holds the focus. But I need that the controls loose the focus and the form really gets the focus so it will be ready itself for keyboard input. The only way that seems to work is to set all controls to visible := false and then to set all controls to visible true again - not a pretty way to do this. Other trials failed (ActiveControl, Focused). Any ideas for a better way to do this? Thanks for any hints, Martin ---------------------------------------------------------------------- eny · 2010-05-10 13:40 I'm not sure why you would ever want to do that  Can't you just set KeyPreview to true and test whether or not a keypress needs to be captured? Or: you can put a panel on the form that has the same color as your form and no bevel or caption so it's invisible. And set width and height to 1, so if fits anywhere. Set Tabstop to false. Now if you set the focus to this panel, also set the form's KeyPreview to true. This basically does what you want. ---------------------------------------------------------------------- Martin V · 2010-05-10 20:30 eny, yes, a tPanel would fit the purpose. But I wonder if there is no possibility to loose the focus of all controls in a form, because in this case, the focus would drop back to the form handle. tPanel should work indeed, but is not useful for me because it is an existing project and I do not want to change the program basics because of backward compatibility. Martin