Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to resize a controls at runtime with the mouse????
Message
From
30/08/2004 16:41:57
 
 
To
30/08/2004 14:23:11
Eric Gauthier
Transcontinental Interweb (Montreal)
Boucherville, Quebec, Canada
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00937751
Message ID:
00937824
Views:
8
This message has been marked as the solution to the initial question of the thread.
Hi Eric.

I want to know how to resize some kind of controls at runtime with the mouse like in design time. Exemple : a textbox.

Here is a little test form that resizes the shape on it to give you an idea of how this can be done:
DEFINE CLASS test AS form


	DoCreate = .T.
	Caption = "Form1"
	chorizontal = ""
	cvertical = ""
	Name = "Form1"
	lresizing = .F.


	ADD OBJECT shape1 AS shape WITH ;
		Top = 41, ;
		Left = 62, ;
		Height = 61, ;
		Width = 107, ;
		Name = "Shape1"


	PROCEDURE shape1.MouseDown
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		*** Check for left mouse button
		IF nButton = 1
		  *** Now see if we are on a border of the shape
		  IF BETWEEN( nXCoord, This.Left - 2, This.Left + 2 ) OR ;
		     BETWEEN( nXCoord, This.Left + This.Width - 2, This.Left + This.Width + 2 )
		    IF BETWEEN( nXCoord, This.Left - 2, This.Left + 2 )
		      Thisform.cHorizontal = 'LEFT'
		    ELSE
		      Thisform.cHorizontal = 'RIGHT'
		    ENDIF
		  ELSE
		    Thisform.cHorizontal = ''
		  ENDIF
		  IF BETWEEN( nYCoord, This.Top - 2, This.Top + 2 ) OR ;
		     BETWEEN( nYCoord, This.Top + This.Height - 2, This.Top + This.Height + 2 )
		    IF BETWEEN( nYCoord, This.Top - 2, This.Top + 2 )
		      Thisform.cVertical = 'TOP'
		    ELSE
		      Thisform.cVertical = 'BOTTOM'
		    ENDIF
		  ELSE
		    Thisform.cVertical = ''
		  ENDIF
		  *** If we are resizing, change the cursor
		  IF EMPTY( Thisform.cHorizontal ) AND EMPTY( Thisform.cVertical ) 
		    Thisform.lResizing = .F.
		  ELSE
		    Thisform.lResizing = .T.
		    *** Now set the mouse pointer
		    This.MousePointer = 5 && size
		  ENDIF
		ENDIF
	ENDPROC


	PROCEDURE shape1.MouseMove
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		LOCAL lnRight, lnBottom

		IF Thisform.lResizing
		  IF Thisform.cHorizontal == 'LEFT'
		    lnRight = This.Left + This.Width
		    This.Left = nXCoord
		    *** error checking needed here to ensure width does 
		    *** not get too small
		    This.Width = ABS( lnRight - This.Left )
		  ELSE
		    IF Thisform.cHorizontal = 'RIGHT'
		      *** need a check here for legal movement
		      This.Width = ABS( nXCoord - This.Left )
		    ENDIF
		  ENDIF
		  IF Thisform.cVertical == 'TOP'
		    lnBottom = This.Top + This.Height
		    This.Top = nYCoord
		    *** error checking needed here to ensure height does 
		    *** not get too small
		    This.Height = ABS( lnBottom - This.Top )
		    This.Top = nYCoord
		  ELSE
		    IF Thisform.cVertical = 'BOTTOM'
		      *** need a check here for legal movement
		      This.Height = ABS( nYCoord - This.Top )
		    ENDIF
		  ENDIF
		ENDIF
		    
	ENDPROC


	PROCEDURE shape1.MouseUp
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		IF nButton = 1
		  IF Thisform.lResizing 
		    Thisform.lResizing = .F.
		    Thisform.cVertical = ''
		    Thisform.cHorizontal = ''
		    This.MousePointer = 0 
		  ENDIF
		ENDIF
	ENDPROC


ENDDEFINE
Previous
Reply
Map
View

Click here to load this message in the networking platform