>>Though it's possible that nothing has control at the time, i.e. thisform.activecontrol may be null, so some checking needs to be done.
>
>What if I add a property say lHasFocus, then set its value each time when the event GotFocus and LostFocus are triggered...
>will I still miss anything?
The framework I use has that, so I guess it's been tried already. Why not. I've also seen frameworks where a form-level method would do all the checking and return a reference to the active object, so you'd have something like
if thisfrom.WhatIsActiveControl()=this
which also worked. As usual, it can be done three ways in Fox, or isn't worth doing :).
It's possible that other code may run while your control still has focus - timer events, grid refreshes, toolbar buttons code, OKL. These don't take focus away.