Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't call setfocus() from init() ??????
Message
 
 
To
30/01/2003 13:56:43
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00747302
Message ID:
00747368
Views:
14
>I am receiving the error:
>
>Cannot call setfocus() from within a when, valid, rangehigh or rangelow.
>
>BUT - I am calling the setfocus in my form's init() method!!
>This has me COMPLETELY confused. I always call setfocus() from my form's init. How can this be happening?
>
>TIA

David,
You should NEVER call SetFocus from the Init. This messes up the normal sequence of events for form instantiation.

The normal sequence is Load, Init, Show, Activate, GotFocus (LISAG). When you call the SetFocus from the Init, you get the following:

Load
Init
Activate
Gotfocus
Init && any code after the call to SetFocus
Show

Depending on what your form does at each step, things could get messed up. It would be better, IMO, to do this in the Activate (or method called from the activate). If your form is modal then you won't have to worry about the Activate firing more than once. If not, you could set a form level property in the Activate and check it to determine if it the first time Activate has run. If not, you know the user has gone to another form and come back.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform