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
31/05/2005 09:08:54
 
 
To
31/05/2005 08:16:38
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01018452
Message ID:
01018668
Views:
16
Christian,

Your code looks awesome - but its missing definitions for ALLOCMEM(), READINT() and WRITEINT(). I googled ALLOCMEM() function and I think this is a function from your personal library vs. the one described on MSDN? On a hunch, I checked the VFP2C32.FLL included in your demo, saw that ALLOCMEM() was indeed included, set libary to VFP2C32, but got error 43 - not enough memory to complete this operation.

I think I follow what you're doing - you're calculating the region that a toolbar can be safely moved without docking, then using the ClipRegion API to prevent the mouse from moving outside this region when a user is dragging the toolbar? Your RECT class acts a proxy for the RECT structure required by the ClipRegion API. Cool!

Malcolm



>
>how about this one :))
>
>
>public oToolbarTest
>oToolbarTest = createobject("clsToolbarTest")
>oToolbarTest.Show()
>
>DECLARE INTEGER ClipCursor IN user32.dll INTEGER
>
>* 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(20,20)
>* register this toolbar as the object to move
>This.cntMain.oMover.Visible = .T.
>ENDFUNC
>
>enddefine
>
>* custom label class that captures move request and transfers to linked object
>define class clsMover as Label
>
>Caption = "Click and drag me!"
>BackStyle = 0
>AutoSize = .T.
>
>* holds reference to object being moved
>oLinkedObject = .Null.
>oForm = .NULL.
>oRect = .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
>	THIS.oRect = CREATEOBJECT('RECT')
>ENDFUNC
>
>* clear linked object
>function Destroy()
>	This.oLinkedObject = .NULL.
>	THIS.oForm = .NULL.
>	THIS.oRect = .NULL.
>endfunc
>
>function MouseDown(nButton, nShift, nXCoord, nYCoord)
>if nButton = 1
>	with This
>		.OriginalXPos = nXCoord
>		.OriginalYPos = nYCoord
>		.OriginalLeft = .oLinkedObject.Left
>		.OriginalTop  = .oLinkedObject.Top
>		.oRect.mLeft  = .oForm.Left + nXCoord + 4
>		.oRect.mTop   = .oForm.Top + nYCoord + 19
>		.oRect.mRigth = nXCoord + .oForm.Left + .oForm.Width - .oLinkedObject.Width
>		.oRect.mBottom = nYCoord + .oForm.Top + .oForm.Height - .oLinkedObject.Height
>		ClipCursor(.oRect.Address)
>	endwith
>endif
>endfunc
>
>function MouseMove(nButton, nShift, nXCoord, nYCoord)
>IF nButton = 1
>	WITH THIS
>	 .OriginalLeft = .OriginalLeft + nXCoord - .OriginalXPos
>	 .OriginalTop = .OriginalTop + nYCoord - .OriginalYPos
>	 .oLinkedObject.Move(.OriginalLeft,.OriginalTop)
>	 .oForm.Draw()
>	ENDWITH
>ENDIF
>
>ENDFUNC
>
>FUNCTION MouseUp(nButton, nShift, nXCoord, nYCoord)
>	IF nButton = 1
>		ClipCursor(0)
>	ENDIF
>ENDFUNC
>
>ENDDEFINE
>
>DEFINE CLASS RECT AS Exception
>	>	Address = 0
>	SizeOf = 16
>	PROTECTED Embedded	
>	Embedded = .F.
>	mLeft = 0
>	mTop = 0
>	mRigth = 0
>	mBottom = 0
>	>	PROCEDURE Init(lnAddress)
>		IF PCOUNT() = 0
>			THIS.Address = AllocMem(THIS.SizeOf)
>			IF THIS.Address = 0
>				ERROR(43)
>				RETURN .F.
>			ENDIF
>		ELSE
>			ASSERT TYPE('lnAddress') = 'N' AND lnAddress != 0 MESSAGE 'Address of structure must be specified!'
>			THIS.Address = lnAddress
>			THIS.Embedded = .T.
>		ENDIF
>	ENDFUNC
>	>	PROCEDURE Destroy
>		IF !THIS.Embedded
>			FreeMem(THIS.Address)
>		ENDIF
>	ENDPROC
>	>	PROCEDURE mLeft_Access
>		RETURN ReadInt(THIS.Address)
>	ENDPROC
>	>	PROCEDURE mLeft_Assign(lnNewVal)
>		WriteInt(THIS.Address,lnNewVal)
>	ENDPROC
>	>	PROCEDURE mTop_Access
>		RETURN ReadInt(THIS.Address+4)
>	ENDPROC
>	>	PROCEDURE mTop_Assign(lnNewVal)
>		WriteInt(THIS.Address+4,lnNewVal)
>	ENDPROC
>
>	PROCEDURE mRigth_Access
>		RETURN ReadInt(THIS.Address+8)
>	ENDPROC
>	>	PROCEDURE mRigth_Assign(lnNewVal)
>		WriteInt(THIS.Address+8,lnNewVal)			
>	ENDPROC
>
>	PROCEDURE mBottom_Access
>		RETURN ReadInt(THIS.Address+12)
>	ENDPROC
>	>	PROCEDURE mBottom_Assign(lnNewVal)
>		WriteInt(THIS.Address+12,lnNewVal)						
>	ENDPROC
>
>ENDDEFINE
>
>
>
>Regards
>Christian
Malcolm Greene
Brooks-Durham
mgreene@bdurham.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform