Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Program Error - Cannot call SetFocus from within ...
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00120667
Message ID:
00131788
Vues:
53
>Oleg,
>
>Your code would surpress the error but would not move focus where you want it to go because after the Valid returns .T. the LostFocus will set focus to the next control in the tab order.
>
>The best solution is to realize that the purpose of the Valid event is to determine whether or not you will allow focus to leave the control and that is it. Deciding where to go only comes into play aftert you have decided to allow the user to leave. The LostFocus is the event that fires when the control will actually lose focus and that is where you should setfocus.


My apologies on that. I remember, that I was able to do setfocus() on the call of modal form from within the valid event ( but cannot reproduce that now).
But, there is still a way to set/control the focus from within the valid event.

You should remember, that the valid event in VFP 5.0 can return not just true or
false, but the integer values also.

Instead of ( in valid)

if
thisform.some_object.setfocus()
else
return .f.
endif

write:
if
return thisform.some_object.tabindex-this.tabindex
else
return 0
endif

This code will set the focus on desirable object and prevent exit, if the condition has not met.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform