Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Move a toolbar by dragging on child control vs. border/t
Message
From
30/05/2005 13:13:21
 
 
To
30/05/2005 08:53:18
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01018452
Message ID:
01018560
Views:
8
This message has been marked as a message which has helped to the initial question of the thread.
Hello,

having read you other thread's .. i think using a form instead of a toolbar is easier since you don't have to prevent docking behaviour, which is almost impossible if you want to be able to move the control of the screen
public oToolbarTest
oToolbarTest = createobject("clsToolForm")
oToolbarTest.Show()

DEFINE CLASS clsToolForm AS Form
	BorderStyle = 0
	ControlBox = .F.
	Height = 100
	Width = 200
	Titlebar = 0

	ADD OBJECT cntMain AS Container WITH Height = 100, Width = 200

	FUNCTION Init
		THIS.AddObject("oMover","clsMover",THIS)
		THIS.oMover.Move(10,6)
		THIS.oMover.Visible = .T.
	ENDFUNC

ENDDEFINE

define class clsMover as Label

Caption = "Click and drag me!"
BackStyle = 0
AutoSize = .T.

* holds reference to object being moved
oLinkedObject = .Null.

* remember mouse position at start of drag
OriginalXpos = 0
OriginalYpos = 0

* remember original object being moved's position
OriginalLeft = 0
OriginalTop = 0

FUNCTION Init(loLinked)
 THIS.oLinkedObject = loLinked	
ENDFUNC

* clear linked object
function Destroy()
 This.oLinkedObject = .Null.
endfunc

function MouseDown
lparameters nButton, nShift, nXCoord, nYCoord
if nButton = 1
	with This
		.OriginalXPos = nXCoord
		.OriginalYPos = nYCoord
		.OriginalLeft = This.oLinkedObject.Left
		.OriginalTop = This.oLinkedObject.Top
	 endwith
endif
endfunc

function MouseMove
lparameters nButton, nShift, nXCoord, nYCoord
if nButton = 1
	WITH THIS
		.OriginalLeft = .OriginalLeft + nXCoord - .OriginalXPos
		.OriginalTop = .OriginalTop + nYCoord - .OriginalYPos
		.oLinkedObject.Move(.OriginalLeft,.OriginalTop)
	ENDWITH 
endif
endfunc

enddefine
Regards
Christian
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform