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:56:54
 
 
To
30/05/2005 13:34:08
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01018452
Message ID:
01018566
Views:
9
This message has been marked as a message which has helped to the initial question of the thread.
Hi,

the focus issue came to my mind after i posted ..

maybe this one help's ..
public oToolbarTest
oToolbarTest = createobject("clsToolbarTest")
oToolbarTest.Show()

* standard toolbar
define class clsToolbarTest as Toolbar

ShowWindow = 1 && in top level form

add object cntMain as Container with height = 100, width = 200

function Init()
* add object that manages the move
This.cntMain.AddObject( "oMover", "clsMover",THIS,_SCREEN)
This.cntMain.oMover.Move( 10, 6 )
* register this toolbar as the object to move
This.cntMain.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.
oForm = .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,loForm)
	THIS.oLinkedObject = loLinked	
	THIS.oForm = loForm
ENDFUNC

* clear linked object
function Destroy()
	This.oLinkedObject = .NULL.
	THIS.oForm = .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 = MIN(MAX(.OriginalLeft + nXCoord - .OriginalXPos,0),.oForm.Width-.oLinkedObject.Width)
		.OriginalTop = MIN(MAX(.OriginalTop + nYCoord - .OriginalYPos,0),.oForm.Height-.oLinkedObject.Height)
		.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