Hi John,
What I don't understand:
Why is ActiveControl empty in my chkBox.When() if I used a hotkey to move the cursor to the chkBox? If I click the chkBox with the mouse, ActiveControl is not empty?
Are you saying that just using {alt+?} puts me into the menu (throwing away the ActiveControl in the process), then returns to the form to continue trying to move the focus to the control indicated by the {alt+?}?
>Bill,
> any time you use "Thisform.ActiveControl" always use it this way:
>
>if type('Thisform.ActiveControl') = 'O'
> lo = Thisform.ActiveControl
>endif
>
>This will stop the error you are getting. If no control on the form has focus you will get the error if you don't check it first. I think the menu commands are fine except that the Alt+... will remove focus from the form and put it on the menu instead so your code will never work. You may have to add a property to the form to hold a pointer to the current object and update it with the gotfocus of each control you expect to be in.
>
>John.
>
>
>>I have fixed this problem, but I want to know why it happens.
>>
>>Define myChkBox as ChkBox
>> Caption = 'Re\<fused'
>> Procedure When()
>> local lo
>> lo = Thisform.ActiveControl
>> This.Value = !This.Value
>> lo.SetFocus()
>> Return .F.
>> EndProd
>>EndDefine
>>
>>This works just fine when the user clicks on the chkBox with the mouse, but if the user uses {alt+f} to do it, error "ACTIVECONTROL IS NOT AN OBJECT" and debugger shows "" for ActiveControl.
>>
>>Why does the keyboard shortcut throw away the ActiveControl?
Bill Morris