Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Steve Bloodsworth
  Where is Steve Bloodsworth?
 Sarasota
 Florida - United States
 Steve Bloodsworth
 To: Boudewijn Lutgerink
  Where is Boudewijn Lutgerink?
 Paalbalk Huissen
 Netherlands
 Boudewijn Lutgerink
 Tags
Subject: RE: Hook into form resize?
Thread ID: 25129 Message ID: 25271 # Views: 19 # Ratings: 0
Version: Visual FoxPro 7 Category: Forms
Date: Monday, June 30, 2003 4:45:04 PM         
   


> > Is there a way to hook into the forms resize event without manually adding code to the resize event??
> >
> >
> > ---
> >
> > www.foxite.com - The Home of the Visual FoxPro Experts
>
> I first place some code in the resize event of the form. This is:
>
> This.oFormBehavior.FormResize(This)
> 

>
> The oFormBehavior is an object of custom class that has the following code in the FormResize Method:
>
>
> LPARAMETERS toForm
> LOCAL lnScaleWidth, lnScaleHeight
> 
> WITH toForm
> 	* Lock the form
> 	*
> 	.LockScreen     = .T.
>    
> 	* Determine the resize scale factors
> 	*
> 	lnScaleWidth    = .Width  / THIS.nOldWidth
> 	lnScaleHeight   = .Height / THIS.nOldHeight
> 
> 	* Save the current size
> 	*
> 	THIS.nOldWidth  = .Width
> 	THIS.nOldHeight = .Height
> 
> 	* Resize all contained controls
> 	*
> 	ResizeContainer(toForm, lnScaleHeight, lnScaleWidth)
> 
> 	* Refresh the form
> 	*
> 	.Refresh()
>    
> 	* Unlock the screen
> 	*
> 	.LockScreen     = .F.
> ENDWITH
> 

>
> THIS.nOldWidth and THIS.nOldHeight of the control are determined in the init of the control
>
>
> LPARAMETERS toForm
> 
> #INCLUDE Include\AppInc.h
> 
> WITH toForm
> 
> 	* Save the original size
> 	*
> 	THIS.nOldWidth  = .Width
> 	THIS.nOldHeight = .Height
> 
> 	* Set the maximum size
> 	*
> 	.MaxHeight      = .Height * 1.25
> 	.MaxWidth       = .Width  * 1.25
> 
> 	* Set the minimum size
> 	*
> 	.MinHeight      = .Height / 1.25
> 	.MinWidth       = .Width  / 1.25
> 
> 	* Enable the maximize button and set the form border
> 	*
> 	.maxbutton      = .T.
> 	.BorderStyle    = 3
> ENDWITH
> 

>
> As you could see the FormResize calls the resizecontainer function. That is a recursive function.
> Here it is:
>
>
> FUNCTION ResizeContainer(toContainer, tnScaleHeight, tnScaleWidth)
> 
> 	* Function....: ResizeContainer
> 	* Called by...: FormResizeBehavior
> 	LOCAL lnI
> 
> 	WITH toContainer
> 		DO CASE
> 			CASE UPPER(.BASECLASS) = 'PAGEFRAME'
> 				FOR m.lnI = 1 TO .PAGECOUNT
> 					ResizeContainer(.PAGES[lnI], tnScaleHeight, tnScaleWidth)
> 				ENDFOR
> 
> 			OTHERWISE
> 				FOR m.lnI = 1 TO .CONTROLCOUNT
> 
> 					IF TYPE('.Controls[lnI].Top') = 'N'
> 						.CONTROLS[lnI].TOP      = ROUND(.CONTROLS[lnI].TOP      * tnScaleHeight, 0)
> 					ENDIF
> 
> 					IF TYPE('.Controls[lnI].Left') = 'N'
> 						.CONTROLS[lnI].LEFT     = ROUND(.CONTROLS[lnI].LEFT     * tnScaleWidth, 0)
> 					ENDIF
> 
> 					IF TYPE('.Controls[lnI].Height') = 'N'
> 						.CONTROLS[lnI].HEIGHT   = ROUND(.CONTROLS[lnI].HEIGHT   * tnScaleHeight, 0)
> 					ENDIF
> 
> 					IF TYPE('.Controls[lnI].Width') = 'N'
> 						.CONTROLS[lnI].WIDTH    = ROUND(.CONTROLS[lnI].WIDTH    * tnScaleWidth, 0)
> 					ENDIF
> 
> 					IF TYPE('.Controls[lnI].FontSize') = 'N'
> 						.CONTROLS[lnI].FONTSIZE = ROUND(.CONTROLS[lnI].FONTSIZE * tnScaleHeight * tnScaleWidth, 0)
> 					ENDIF
> 
> 					IF UPPER(.CONTROLS[lnI].BASECLASS) ; 
> 						$ 'CONTAINER,COLUMN,PAGEFRAME,PAGE,COMMANDGROUP,FORM,OPTIONGROUP,PAGEFRAME'
> 
> 						ResizeContainer(.CONTROLS[lnI], tnScaleHeight, tnScaleWidth)
> 					ENDIF
> 				ENDFOR
> 		ENDCASE
> 	ENDWITH
> 
> 	RETURN
> ENDFUNC
> 

>
> this code comes from the Fairframe framework that was originally designed by Maurice de Beyer. Fairtree bought his framework and unfortunately went bankrupt in the turmoil of 9-11.
>
> Boudewijn Lutge®ink
> Boudewijn.Lutgerink@foxite.com
> "Unless something happens that we can't predict, I don't think a lot will happen."



Boudewijn,

you listed:

THIS.nOldWidth and THIS.nOldHeight of the control are determined in the init of the control


LPARAMETERS toForm

#INCLUDE Include\AppInc.h

WITH toForm

   * Save the original size
   *
   THIS.nOldWidth = .Width
   THIS.nOldHeight = .Height

   * Set the maximum size
   *
   .MaxHeight = .Height * 1.25
   .MaxWidth = .Width * 1.25

   * Set the minimum size
   *
   .MinHeight = .Height / 1.25
   .MinWidth = .Width / 1.25

   * Enable the maximize button and set the form border
   *
   .maxbutton = .T.
   .BorderStyle = 3
ENDWITH



In what area does this code go? The init of the control? Which control?

I'd love to give this function a try, but am stuck at this part :)

Thanks again,

~Steve



COMPLETE THREAD
Hook into form resize? Posted by Michael Gill @ 6/25/2003 10:10:14 PM
RE: Hook into form resize? Posted by mike castillo @ 6/26/2003 1:56:58 AM
RE: Hook into form resize? Posted by Karben Selim Mejia @ 6/26/2003 4:57:35 PM
RE: Hook into form resize? Posted by Boudewijn Lutgerink @ 6/29/2003 5:19:13 AM
RE: Hook into form resize? Posted by Steve Bloodsworth @ 6/30/2003 4:45:04 PM
RE: Hook into form resize? Posted by Boudewijn Lutgerink @ 7/1/2003 8:40:42 AM