FOR I=1 TO THIS.CONTROLCOUNT
WITH THIS.CONTROLS(I)
IF TYPE( ".ANCHOR ")# "U "
.ANCHOR=240
ENDIF
IF TYPE( ".FontSize ")# "U "
.FONTSIZE=.FONTSIZE……
[/Quote]
FOR I=1 TO THIS.CONTROLCOUNT
WITH THIS.CONTROLS(I)
IF TYPE( ".ANCHOR ")# "U "
.ANCHOR=240
ENDIF
IF TYPE( ".FontSize ")# "U "
.FONTSIZE=.FONTSIZE……
[/Quote]
很强大,再补充页框里面的代码。
FOR m.i=1 TO THIS.CONTROLCOUNT
WITH THIS.CONTROLS(m.i)
IF TYPE( ".ANCHOR ")# "U"
.ANCHOR=240
ENDIF
*!* IF TYPE( ".FontSize")# "U"
*!* ?TYPE( ".FontSize")
*!* .FONTSIZE=.FONTSIZE*(SYSMETRIC(1)/THIS.WIDTH)
*!* ENDIF
ENDWITH
IF THISFORM.Controls[m.i].Baseclass$"Pageframe"
*Loop through each page of the pageframe
FOR m.j = 1 TO THISFORM.Controls[m.i].PageCount
WITH THISFORM.Controls[m.i].pages[m.j]
*loop through all the controls on the page
FOR m.k = 1 TO .ControlCount
WITH .CONTROLS(m.k)
IF TYPE( ".ANCHOR ")# "U"
.ANCHOR=240
ENDIF
ENDWITH
ENDFOR
ENDWITH
ENDFOR
ENDIF
ENDFOR
FOR I=1 TO THIS.CONTROLCOUNT
WITH THIS.CONTROLS(I)
IF TYPE(".ANCHOR")#"U"
.ANCHOR=240
ENDIF
IF TYPE(".FontSize")#"U"
.FONTSIZE=.FONTSIZE*(SYSMETRIC(1)/THIS.WIDTH)
ENDIF
ENDWITH
ENDFOR
到VFP提供的Samples里边研究以下内容:
Visual FoxPro 9.0 Samples
Resize and Reposition Controls at Run Time Sample
File: ...\Samples\Solution\Forms\Cresize.scx
A user can resize this sample form as desired. The controls on the form are resized or repositioned relative to the new Height and Width properties of the form.
This form uses the resizable class in ...\Samples\Classes\Samples.vcx to manage resizing and repositioning of the controls. The following line of code is added to the Resize event of the form, calling the AdjustControls method of the resizable class:
THIS.Resizable2.AdjustControls
In the Init of the resizable class, code loops through all the controls in the form, storing their positions and sizes relative to the form in an array. When the form is resized, the AdjustControls method resizes and repositions the controls to their relative sizes and positions.
You can add more controls to the form and the new controls will also be resized and repositioned.
The RepositionList and ResizeList properties contain a space-delimited list of all the classes that you want to reposition and resize. If you do not want a certain class to be resized, remove it from the ResizeList.
You can prevent a user from making the form too small for the objects contained on it by setting the form's MinHeight and MinWidth properties.