Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to find out the control focus is jumping to?
Message
De
18/12/2008 19:16:08
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01368256
Message ID:
01368717
Vues:
6
>>>>>>My form have quite a number of controls.
>>>>>>Your idea should work fine if I have "exclude all other controls, get the listbox populated with values only if focus is about to be set to 1 or 2 controls" scenario.
>>>>>>However, in my case, it is exactly the reverse scenario, I want to "do nothing" only for 1 or 2 controls and get the listbox populated with values for the rest of controls.
>>>>>>
>>>>>>If I were to do it as you have suggested, that means I will have to add code to GetFocus event of almost all controls in the form and I think I can easily forget about adding the same code, if in the future I need to add new control to the form.
>>>>>
>>>>>Don't remember, can you bind the GotFocus event?
>>>>
>>>>Hi,
>>>>I couldn't figure out how can a bind of GotFocus event help in this case, care to elaborate?
>>>
>>>If ALL controls are placed in the form (not in some container)
>>>The you could use this (in Init event of the form):
>>>
>>>FOR EACH oControl IN thisform.Controls
>>>    IF PEMSTATUS(oControl, "GotFocus", 5) AND;
>>>       NOT INLIST(UPPER(oControl.Name), PUT THE NAMES OF CONTROLS YOU WANT TO EXCLUDE IN UPPER CASE HERE)
>>>       BINDEVENT(oControl,"GotFocus", thisform,"PopulateListBox", 1)
>>>    ENDIF
>>>NEXT
>>>
>>>If you use some container in that form (PageFrame, Container, etc) you should do this as a method in the form and call it recursively for each container.
>>
>>Thanks alot!
>>I can't think of a better way than yours!!!
>>
>>Btw, could you give me a clue, how do I get my name up there in the message footer so that you can CC me?
>
>O, I can :-)
>Just use subclasses for the VFP main classes and all your life will become much easier.
>Yes, at the beginning it will be hard to change all of your controls, but believe me, that work is worth it :-)
>I already sent you info how to change your account.

I understand using subclasses could be a nice solution, at least it will be easier to trace codes compare to the BindEvent solution.

However, in this case, I don't think the subclasses will be reused in the future (at least it won't be often), I mean it is not normal to have a form that requires the same facility.

Come to think about it seriously, if I were to take the trouble to create the subclasses as you have suggested, I hope not to fix the action to "populate a listbox" only. I prefer it to be any action but to do so, it seems that I better go back to BindEvent which I can determine an action by passing it proper delegates, I strongly think that will be better way compare to a fix action which is a method in subclass...
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform