Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to trap a change in a ListBox after a MESSAGEBOX()
Message
De
11/03/2016 14:56:17
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
How to trap a change in a ListBox after a MESSAGEBOX()
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Divers
Thread ID:
01632877
Message ID:
01632877
Vues:
157
Dear All

I'm stuck with two minor but still annoying glitches in a form, and hoping that someone can help me to sort it out.

In the form there is a list that is keeping track of the current item. When the user clicks on an item, the list value is changed, as usual.

The first problem is that a) if the list does not have focus, b) and the user leaves the control that has focus by clicking an item in the list, c) and a message box is issued during the event sequence that goes before focus is passed to the list, the list value and its index are not changed.

The second problem occurs, after the above sequence, a) if the focus goes back to the other control, the highlighted item is recoordinated with the list value and index (we could consider that this is not a problem at all, since at least value and highlight are now in sync, but this change is made without direct user intervention).

Hopefully, the following program will help me to demonstrate this:
LOCAL loForm AS aForm

m.loForm = CREATEOBJECT("aForm")

m.loForm.Show(1)

DEFINE CLASS aForm AS Form
	ADD OBJECT theList AS aList
	ADD OBJECT theText AS aTextBox WITH Left = 100
ENDDEFINE

DEFINE CLASS aList AS ListBox

	PROCEDURE Init

		This.AddItem("Item 1")
		This.AddItem("Item 2")
		This.AddItem("Item 3")
		This.ListIndex = 1

	ENDPROC

	PROCEDURE InteractiveChange

		WAIT WINDOW "InteractiveChange(): " + TRANSFORM(This.ListIndex) + "/" + This.Value NOWAIT NOCLEAR

	ENDPROC

	PROCEDURE ProgrammaticChange
	
		WAIT WINDOW "ProgrammaticChange(): " + TRANSFORM(This.ListIndex) + "/" + This.Value NOWAIT NOCLEAR

	ENDPROC

	PROCEDURE Click

		WAIT WINDOW "Click(): " + TRANSFORM(This.ListIndex) + "/" + This.Value NOWAIT NOCLEAR

	ENDPROC

ENDDEFINE

DEFINE CLASS aTextBox AS TextBox

	PROCEDURE Valid

		IF !EMPTY(This.Value)
			MESSAGEBOX("Some validation...")
		ENDIF

	ENDPROC

ENDDEFINE
Steps to reproduce it:
1. Run the program
2. Click on the list items, the information window is updated.
3. Enter the textbox, leave it empty, and return to the list. All is ok.
4. Enter the textbox again, but insert some characters.
5. Click on a different item in the list. A message box pops up. Click Ok.
6. First problem: the highlighted item in the list is the one clicked on step 5, but the list value and index do not change.
7. Enter the textbox again.
8. Second problem: the highlight moves by itself.

Am I doing anything wrong, here? Is there a way this can be circumvented?
----------------------------------
António Tavares Lopes
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform