Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MoverListBox with MoverBars = .T.
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
The Mere Mortals Framework
Titre:
MoverListBox with MoverBars = .T.
Divers
Thread ID:
00890604
Message ID:
00890604
Vues:
60
I've run into a problem when using a mover control with MoverBars set to .T.. My particular implementation is a subclass of the MoverContainer in the cMover library, but I was able to reproduce the problem in the UserGroups form of the sample app which uses the MvrGroupsObj (kCustCtl) based on the kMoverObj.

The problem occurs when you move items from the full list to the selected list, change the order of the items, then attempt to delete items from the selected list after their position in the list has changed. The item that is restored to the full list is the item originally in the selected position, not the item currently in the .List[N] position.

I've come up with a modification to the MoverListBox's DragDrop event (cMover.vcx) that will solve the problem for my particular conditions as well as those in the sample app. I'd like to modify my base class, but I'm concerned that my solution, while it works in the two examples I've tried, is not a generic fix and will come back to haunt me in future implementations.

This is the original code in the MoverListBox DragDrop Event:
	FOR lnCounter = 1 TO oSource.ListCount
	  IF oSource.Selected(lnCounter) AND !oSource.Isdimmed(lnCounter)
	    oSource.DupeRow(@laSource, lnCounter)
	    This.AddItemToRowSourceArray(@laSource, .T.)
	    IF This.RowSourceType = 0
	  		This.AddListItem(laSource[1,1], laSource[1, 2])
	    ENDIF
	    oSource.MarkRow(lnCounter)
	  ENDIF
	ENDFOR
This is the code with my modifications:
*-- LW 3/29/2004 - added lnIndex to correctly remove
*                  items whose position had been changed
*                  by MoverBar in the selected array


LOCAL lcArray, lnIndex
lcArray = oSource.RowSource

FOR lnCounter = 1 TO oSource.ListCount
         IF oSource.Selected(lnCounter) AND !oSource.Isdimmed(lnCounter)
          
		*Search the RowSouce for the selected item. Which row was it in when it was originally
		*added? If it has been moved in the selected list, the row in the list will not be the same and
		*the wrong row will be duplicated by the DupeRow method below
		lnIndex = ASCAN(&lcArray, oSource.List(lnCounter),1,-1,1,8)

		* change subsequent references to lnCounter -> lnIndex
		*oSource.DupeRow(@laSource, lnCounter) && this is the original Framework code
		oSource.DupeRow(@laSource, lnIndex)

		THIS.AddItemToRowSourceArray(@laSource, .T.)
		IF THIS.RowSourceType = 0
			THIS.AddListItem(laSource[1,1], laSource[1, 2])
		ENDIF

		* change subsequent references to lnCounter -> lnIndex
		*oSource.MarkRow(lnCounter) && this is the original Framework code
		oSource.MarkRow(lnIndex)  
         
	ENDIF
ENDFOR
Has anyone else run into this problem in their apps? Have you found a more generic fix? Will my fix work in your implementation? I'd appreciate a second (or third or fourth or tenth) pair of eyes to detect any gotchas that I'm missing.

Thanks!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform