Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple drag & drop operation
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00665152
Message ID:
01124843
Vues:
31
>I wsan't refering to your reply only. :)

Thanks a million for mailing this class. So, now I have the following code for cntMover (works for values only). I should not probably re-invent the wheel, but I just grabbed the original code by my colleague, then teared it almost apart and made the following class:
**************************************************
*-- Class:        cntmover (c:\mmviscollect\libs\areportcontrols.vcx)
*-- ParentClass:  ccontainer (c:\mmortals\common30\libs\ccontrls.vcx)
*-- BaseClass:    container
*-- Time Stamp:   05/25/06 09:17:03 AM
*-- Mover container 
*
DEFINE CLASS cntmover AS ccontainer


	Width = 376
	Height = 206
	TabIndex = 1
	*-- This property is set to true, then items are moved
	lchanged = .F.
	Name = "cntmover"


	ADD OBJECT lstinput AS clistbox WITH ;
		OLEDragMode = 1, ;
		OLEDropMode = 1, ;
		Anchor = 135, ;
		ColumnCount = 2, ;
		ColumnWidths = "250,0", ;
		RowSourceType = 0, ;
		Height = 182, ;
		ColumnLines = .F., ;
		Left = 4, ;
		MultiSelect = .T., ;
		TabIndex = 10, ;
		Top = 21, ;
		Width = 160, ;
		ZOrderSet = 11, ;
		Name = "lstInput"


	ADD OBJECT lstoutput AS clistbox WITH ;
		OLEDragMode = 1, ;
		OLEDropMode = 1, ;
		Anchor = 45, ;
		ColumnCount = 2, ;
		ColumnWidths = "250,0", ;
		RowSourceType = 0, ;
		Height = 182, ;
		ColumnLines = .F., ;
		Left = 211, ;
		MultiSelect = .T., ;
		TabIndex = 10, ;
		Top = 21, ;
		Width = 160, ;
		ZOrderSet = 11, ;
		Name = "lstOutput"


	ADD OBJECT cmdfeedtoright AS ccommandbutton WITH ;
		Top = 62, ;
		Left = 169, ;
		Height = 22, ;
		Width = 39, ;
		Anchor = 768, ;
		Caption = ">", ;
		Name = "cmdFeedToRight"


	ADD OBJECT cmdfeedalltoright AS ccommandbutton WITH ;
		Top = 88, ;
		Left = 169, ;
		Height = 22, ;
		Width = 39, ;
		Anchor = 768, ;
		Caption = ">>", ;
		Name = "cmdFeedAllToRight"


	ADD OBJECT cmdfeedtoleft AS ccommandbutton WITH ;
		Top = 114, ;
		Left = 169, ;
		Height = 22, ;
		Width = 39, ;
		Anchor = 768, ;
		Caption = "<", ;
		Name = "cmdFeedToLeft"


	ADD OBJECT cmdfeedalltoleft AS ccommandbutton WITH ;
		Top = 140, ;
		Left = 169, ;
		Height = 22, ;
		Width = 39, ;
		Anchor = 768, ;
		Caption = "<<", ;
		Name = "cmdFeedAllToLeft"


	ADD OBJECT lbloptions AS clabel WITH ;
		FontBold = .T., ;
		Caption = "Caption", ;
		Left = 4, ;
		Top = 4, ;
		Width = 44, ;
		Name = "lblOptions"


	*-- Moves one item
	PROCEDURE moveone
		*---------------------- Location Section ------------------------
		*   Library: 	Areportcontrols.vcx
		*   Class: 		Cntmover
		*   Method: 	Moveone()
		*----------------------- Usage Section --------------------------
		*)  Description:
		*)

		*   Scope:      Public
		*   Parameters:
		*$  Usage:
		*$
		*   Returns:
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	05/24/2006 - NN
		*		MODIFIED
		*----------------------------------------------------------------
		lparameters toFrom, toTo
		local lcSelect, lnIndex, lnTotItem
		lnIndex = m.toFrom.listindex
		if m.lnIndex # 0
			lcSelect = toFrom.list(m.lnIndex,1)
			toTo.additem(m.lcSelect)
			toFrom.removeitem(m.lnIndex)
			this.refresh()
			this.lChanged = .t.
		endif
	ENDPROC


	*-- Moves all items
	PROCEDURE moveall
		*---------------------- Location Section ------------------------
		*   Library: 	Areportcontrols.vcx
		*   Class: 		Cntmover  
		*   Method: 	Moveall() 
		*----------------------- Usage Section --------------------------
		*)  Description: 
		*)

		*   Scope:      Public
		*   Parameters: 
		*$  Usage:      
		*$              
		*   Returns:  
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	05/24/2006 - NN 
		*		MODIFIED
		*----------------------------------------------------------------
		lparameters toFrom, toTo
		local lcSelect, lnIndex, lnTotItem
		lnTotItem = toFrom.listcount
		for lnIndex =  1 to m.lnTotItem
			lcSelect = toFrom.list(m.lnIndex,1)
			toTo.additem(m.lcSelect)
		next
		*!*	for lnIndex =  1 to m.lnTotItem
		*!*		toFrom.removelistitem(m.lnIndex)
		*!*	next
		toFrom.Clear()
		this.refresh()
		this.lChanged = .t.
	ENDPROC


	PROCEDURE Refresh
		local loControl
		with this
			store .t. to ;
				.cmdFeedAllToRight.enabled, ;
				.cmdFeedToRight.enabled, ;
				.cmdFeedAllToLeft.enabled, ;
				.cmdFeedToLeft.enabled
			if .lstOutput.listcount = 0
				store .f. to ;
				.cmdFeedAllToLeft.enabled, ;
					.cmdFeedToLeft.enabled
			endif
			if .lstInput.listcount = 0
				store .f. to ;
					.cmdFeedAllToRight.enabled, ;
					.cmdFeedToRight.enabled
			endif
		endwith
	ENDPROC


	PROCEDURE lstinput.DblClick
		This.parent.MoveOne(this, this.Parent.lstOutput)
	ENDPROC


	PROCEDURE lstinput.OLEDragDrop
		*---------------------- Location Section ------------------------
		*   Library: 	Areportcontrols.vcx
		*   Class: 		Cntmover  
		*   Method: 	Lstinput.Oledragdrop() 
		*----------------------- Usage Section --------------------------
		*)  Description: 
		*)

		*   Scope:      Public
		*   Parameters: 
		*$  Usage:      
		*$              
		*   Returns:  
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	05/25/2006 - NN 
		*		MODIFIED
		*----------------------------------------------------------------
		lparameters oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord
		local array laTest2[1]
		local loSource, lnLoop
		loSource = oDataObject.getdata("VFP Source Object",@laTest2)
		if vartype(m.loSource)=='O'
			for lnLoop = m.loSource.listcount to 1 step -1
				if loSource.selected(m.lnLoop)
					loSource.listindex=m.lnLoop
					this.additem(m.loSource.value)
					loSource.removeitem(m.lnLoop)
				endif
			endfor
		endif
		this.Parent.Refresh()
		this.Parent.lChanged = .t. 
	ENDPROC


	PROCEDURE lstoutput.DblClick
		This.parent.MoveOne(this, this.Parent.lstInput)
	ENDPROC


	PROCEDURE lstoutput.OLEDragDrop
		*---------------------- Location Section ------------------------
		*   Library: 	Areportcontrols.vcx
		*   Class: 		Cntmover  
		*   Method: 	Lstoutput.Oledragdrop() 
		*----------------------- Usage Section --------------------------
		*)  Description: 
		*)

		*   Scope:      Public
		*   Parameters: 
		*$  Usage:      
		*$              
		*   Returns:  
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	05/25/2006 - NN 
		*		MODIFIED
		*----------------------------------------------------------------
		lparameters oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord
		local array laTest2[1]
		local loSource, lnLoop
		loSource = oDataObject.getdata("VFP Source Object",@laTest2)
		if vartype(m.loSource)=='O'
			for lnLoop = m.loSource.listcount to 1 step -1
				if loSource.selected(m.lnLoop)
					loSource.listindex=m.lnLoop
					this.additem(m.loSource.value)
					loSource.removeitem(m.lnLoop)
				endif
			endfor
		endif
		this.Parent.Refresh()
		this.Parent.lChanged = .t. 
	ENDPROC


	PROCEDURE cmdfeedtoright.Click
		*---------------------- Location Section ------------------------
		*   Library: 	Areportcontrols.vcx
		*   Class: 		Cntmover
		*   Method: 	Cmdfeedtoright.Click()
		*----------------------- Usage Section --------------------------
		*)  Description:
		*)

		*   Scope:      Public
		*   Parameters:
		*$  Usage:
		*$
		*   Returns:
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	05/24/2006 - NN
		*		MODIFIED
		*----------------------------------------------------------------
		this.Parent.MoveOne(this.Parent.lstInput, this.Parent.lstOutput)  
	ENDPROC


	PROCEDURE cmdfeedalltoright.Click
		*---------------------- Location Section ------------------------
		*   Library: 	Areportcontrols.vcx
		*   Class: 		Cntmover
		*   Method: 	Cmdfeedalltoright.Click()
		*----------------------- Usage Section --------------------------
		*)  Description:
		*)

		*   Scope:      Public
		*   Parameters:
		*$  Usage:
		*$
		*   Returns:
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	05/24/2006 - NN
		*		MODIFIED
		*----------------------------------------------------------------
		this.parent.MoveAll(this.Parent.lstInput, this.Parent.lstOutput) 
	ENDPROC


	PROCEDURE cmdfeedtoleft.Click
		*---------------------- Location Section ------------------------
		*   Library: 	Areportcontrols.vcx
		*   Class: 		Cntmover
		*   Method: 	Cmdfeedtoleft.Click()
		*----------------------- Usage Section --------------------------
		*)  Description:
		*)

		*   Scope:      Public
		*   Parameters:
		*$  Usage:
		*$
		*   Returns:
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	05/24/2006 - NN
		*		MODIFIED
		*----------------------------------------------------------------
		this.Parent.MoveOne(this.Parent.lstOutput, this.Parent.lstInput)   
	ENDPROC


	PROCEDURE cmdfeedalltoleft.Click
		*---------------------- Location Section ------------------------
		*   Library: 	Areportcontrols.vcx
		*   Class: 		Cntmover
		*   Method: 	Cmdfeedalltoleft.Click()
		*----------------------- Usage Section --------------------------
		*)  Description:
		*)

		*   Scope:      Public
		*   Parameters:
		*$  Usage:
		*$
		*   Returns:
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	05/24/2006 - NN
		*		MODIFIED
		*----------------------------------------------------------------
		this.Parent.MoveAll(this.Parent.lstOutput, this.Parent.lstInput)
	ENDPROC


ENDDEFINE
*
*-- EndDefine: cntmover
**************************************************
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform