>>>>>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.
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
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