VFP5 - Moving form by dragging an object on form 
Author Message
 VFP5 - Moving form by dragging an object on form

Does anyone know of a way to move a form by dragging an object on the form so
that the form moves with the object while being dragged?  I have experimented
with  code using the DragOver event and Move method without any luck.  Any help
would be appreciated.



Tue, 29 Aug 2000 03:00:00 GMT
 VFP5 - Moving form by dragging an object on form


Quote:
>Does anyone know of a way to move a form by dragging an object on the form so
>that the form moves with the object while being dragged?  I have experimented
>with  code using the DragOver event and Move method without any luck.  Any help
>would be appreciated.

This just something I threw together in a few minutes, but the premise
should get you going...

Add the following properties to your form:
DrageMode = .F.
PrevMouseX = 0
PrevMouseY = 0

Then in the control you want to be the dragger, fill in the following
events:

MouseDown:
LPARAMETERS nButton, nShift, nXCoord, nYCoord
IF THISFORM.DragMode = .T.
        * We are already dragging, so bug out
        RETURN
ELSE
        * This is a new drag...
        THISFORM.DragMode = .T.
        * Save original mouse coordinates within the form...
        THISFORM.PrevMouseX = nXCoord
        THISFORM.PrevMouseY = nYCoord
ENDIF
DOEVENTS
RETURN

MouseUp:
LPARAMETERS nButton, nShift, nXCoord, nYCoord
* Set DragMode back to FALSE
THISFORM.DragMode = .F.

MouseMove:
LPARAMETERS nButton, nShift, nXCoord, nYCoord
IF THISFORM.DragMode = .T.
        THISFORM.Move(THISFORM.Left + (nXCoord - THISFORM.PrevMouseX),
THISFORM.Top + (nYCoord - THISFORM.PrevMouseY))
        DOEVENTS
        * And set mouse coordinates to new ones so we are ready for
next mousemove...
        THISFORM.PrevMouseX = nXCoord
        THISFORM.PrevMouseY = nYCoord
ENDIF

This works sort of OK.  The movement is choppy, and I was not sure how
to optimize that.  Also, sometime sthe mouse can escape from the
control but yet not register a MouseUp, so the form still moves.  I
would be interested to hear anyone else's ideas...

To go along with this, if you would like code to make sure a control
(or form) stays on screen in its entirety, I can send you that too...I
have that in a ToolBox library with some other useful functions...

Good luck!

JoeK



Tue, 29 Aug 2000 03:00:00 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Moving from form to form in VFP 3.0

2. Accessing Objects on a Mdi Parent form from a Mdi Child form

3. Forms 3.0 & referencing objects in other forms

4. Object arrays and Closing Forms (Proportionally resizing forms)

5. DO FORM & form object naming - HELP

6. move - servercursor - slow when moving form record 1 to record 20.000

7. Forms Forms Forms

8. move - servercursor - slow when moving form record 1 to record 20.000

9. Help: Form.Refresh() doesn't work for active form if mutiple forms on screen

10. Calling a form from a form called by a form problem [PDOXWIN 1.0]

11. VFP5 - Dragging an object from form to Main VFP Window?

12. drag/drop fields to form from table/field popup in design


 
Powered by phpBB® Forum Software