Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Spinner refuses to increase
Message
De
20/04/2006 09:32:09
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01114924
Message ID:
01114932
Vues:
13
I understand your logic and already found out that it all goes well if the refresh is done in the Valid method. However, the official documentation does not mention this limitation and I think it should be mentioned. The Hackers Guide is clearer here:

Although the ControlSource is bound to the control's Value, the item named in ControlSource doesn't get updated until after the control's InteractiveChange is finished.

It also has an advice: Don't test the value of a ControlSource until you reach the Valid event—if you need to test sooner, test the control's Value. In fact, it's better OOP to refer only to the control's Value in its methods and not mention the ControlSource by name. If you reference the actual object named in ControlSource, the code is no longer well encapsulated and the control is no longer as easily reusable. The consequence for your advice would be something like:
PROCEDURE spinner1.InteractiveChange
        local lcC
        lcC = this.controlsource
        &lcC = this.Value
	thisform.refresh()
ENDPROC
>This is not a bug. This happens becuase you bind the control to a form property. IntreactiveChange not change the value of that property, this will be happens after Valid. But refreshing the form you rollback the value of the spinner to value of
>thisform.nEffe
>
>If you change:
>
>PROCEDURE spinner1.InteractiveChange
>        thisform.nEffe = this.Value
>	thisform.refresh()
>ENDPROC
>
>all will works as you expect. I not tested furter what happens with validation.
>
>>This piece of code demonstrates a spinner that refuses to increase or decrease. The crucial part appears to be the instruction to refresh the form in the interactivechange method.
>>
>>Who has a clue? Is it a bug? Or am I the one who is doing something really stupid here.
>>
>>
local ox
>>ox = createobject( 'form1' )
>>ox.visible = .t.
>>read events
>>
>>DEFINE CLASS form1 AS form
>
>>
>>	DoCreate = .T.
>>	Caption = "Form1"
>>	nEffe = 0
>>	Name = "Form1"
>>
>>	ADD OBJECT spinner1 AS spinner WITH ;
>>		Height = 24, ;
>>		Left = 198, ;
>>		Top = 72, ;
>>		Width = 120, ;
>>		ControlSource = "thisform.nEffe", ;
>>		Name = "Spinner1"
>>
>>	PROCEDURE spinner1.InteractiveChange
>>		thisform.refresh()
>>	ENDPROC
>>
>>	procedure destroy
>>		clear events
>>	endproc
>>
>>ENDDEFINE
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform