I am trying to have a control which knows it has been tabbed out of. Explanations may cloud the issue. For reasons beyond my control, the client has specifications. I end up in this situation: There are only three enabled controls on a form
1. MyControl 2. A cancel button 3. The system X close window MyControl.OnExit(sender:TObject) ... Sender is always MyControl ... Active Control is always the Cancel button. Nowhere else to go. ... Can detect X close okay Both blank and non-blank data are valid. The contents of the control provide no clue. When focus leaves the control (occurs before btnCancel.OnEnter), how do I determine that the user clicked cancel rather than tabbing out of the control? Next case, similar, but multi-part key. Two controls and one cancel button. Final case, all forms across the application behave similarly. This is not a one-time kludgde but a specification for how the application functions. I desire strongly to hide this logic in the control or the base form. Thank you for asking. This is certainly nasty. Definitely fighting windows on it. When I say "that fails", I mean my code, not windows. The snippet I included was stripped of debug lines. But the frightening thing is that FShiftKey was returning to a false value without ever having been explicitly touched. Apart from memory corruption which I find hard to swallow, the only resonable explanation seems a nested/recursive sequence of processing messages. Ugh. A simpler solution would be grand. Regards. > [EMAIL PROTECTED] wrote: >> Is there any way for a control to know that it was tabbed out of? >> >> My solutions below fails. It works okay for tabbing forward, but when >> tabbing backward, focus goes into la-la land. > > Back up. What are you actually trying to do? > >> I do detect TAB, but then windows wants me to dealw ith it, and that >> fails. > > Sort of. Windows doesn't want you to deal with it. You've told Windows > that you want to deal with it, so it lets you. > > -- > Rob > > >

