> > 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