Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drag & Drop between containers
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01229584
Message ID:
01229693
Views:
31
This message has been marked as the solution to the initial question of the thread.
>>>>>I had not worked with drag & drop before but working with the sample code in VFP and a few other sources I found it simple to add the needed code to drag & drop a container anywhere on a form.
>>>>>
>>>>>Now I need to drag & drop between containers on the same form and I'm kinda lost. How do I get the object being moved from one container to end up in another container on the same form? It moves within the original container ok, it just won't move out of it to the form or to the other container.
>>>>
>>>>Could you clarify what you are trying to achieve? Do you need to drag&drop the actual controls (i.e. textbox, listbox, etc. or the values in these controls?
>>>
>>>Nick,
>>>I have a form showing a number of stations(containers). Each station (container) has some number of work orders (small containers) within it each showing information about a work order. I want the user to be able to drag a work order (small container) from one station (container) to another as the work proceeds through the shop.
>>>
>>>Put simply, I need to drag a small container from within one large container and drop it into another large container. I will also need only allow them to drop it into certain containers but I figure if I get drag & drop that the restrictions will be easy.
>>
>>One simple way to do it would be not placing the small containers INSIDE the station container, but just above it (in Z-order). I.e. all the containers are created at the same level (say, in the Form or Page) This way you do not need to remove/readd small container object and deal with container hierarchy, but on drop just probe what "target" container is under it. Then set whatever property that tells what target container now it belongs to.
>
>Nick,
>Using just drag & drop, not OleDragDrop, I created the small container on the form. I can move it anywhere on the form but not over another object on the form. Should I still be using OLE?

No, you should use VFP Drag&Drop.
Look at this sample that I just created. The code is in small container MouseMove. You can put that code in your small container class. Use right mouse button to drag.
**************************************************
*-- Form:         form1 (c:\program files\microsoft visual foxpro 9\containerdrag.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   05/31/07 05:57:03 PM
*
DEFINE CLASS form1 AS form


	Top = 0
	Left = 0
	Height = 470
	Width = 724
	DoCreate = .T.
	Caption = "Container Drag"
	Name = "FORM1"


	ADD OBJECT cntstation AS container WITH ;
		Top = 24, ;
		Left = 24, ;
		Width = 312, ;
		Height = 324, ;
		BackColor = RGB(255,255,128), ;
		Name = "cntStation"


	ADD OBJECT cntorder1 AS container WITH ;
		Top = 156, ;
		Left = 348, ;
		Width = 132, ;
		Height = 48, ;
		SpecialEffect = 0, ;
		BackColor = RGB(128,255,255), ;
		Name = "cntOrder1"


	ADD OBJECT cntorder2 AS container WITH ;
		Top = 312, ;
		Left = 432, ;
		Width = 132, ;
		Height = 48, ;
		SpecialEffect = 0, ;
		BackColor = RGB(128,255,255), ;
		Name = "cntOrder2"


	PROCEDURE cntorder1.MouseMove
		LPARAMETERS nbutton, nshift, nxcoord, nycoord
		IF nbutton = 2
			lntop1 = MROW(THISFORM.NAME, 3)
			lnleft1 = MCOL(THISFORM.NAME, 3)
			THIS.DRAG()

			lntop2 = MROW(THISFORM.NAME, 3)
			lnleft2 = MCOL(THISFORM.NAME, 3)

			lntopdiff = lntop2 - lntop1
			lnleftdiff = lnleft2 - lnleft1

			THIS.TOP = THIS.TOP + lntopdiff
			THIS.LEFT = THIS.LEFT + lnleftdiff
		ENDIF
	ENDPROC


	PROCEDURE cntorder2.MouseMove

		LPARAMETERS nbutton, nshift, nxcoord, nycoord
		IF nbutton = 2
			lntop1 = MROW(THISFORM.NAME, 3)
			lnleft1 = MCOL(THISFORM.NAME, 3)
			THIS.DRAG()

			lntop2 = MROW(THISFORM.NAME, 3)
			lnleft2 = MCOL(THISFORM.NAME, 3)

			lntopdiff = lntop2 - lntop1
			lnleftdiff = lnleft2 - lnleft1

			THIS.TOP = THIS.TOP + lntopdiff
			THIS.LEFT = THIS.LEFT + lnleftdiff
		ENDIF
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform