Article ID: | qFRM004 |
Date Revised: | June 05, 1998 |
Keywords: | Builder, ResetToDefault, Field Mapping |
See Also: | Builders |
Question: Why don't form controls respond to size changes of the control class?
Answer: Dragging fields from the project manager or the data environment causes the Height and Width properties of the field mapped objects to be overridden. The Height is overridden with the same value it does inherit from the class. The Width of TextBox subclasses is calculated from the underlying field width. The Width adjustment is useful for normal character fields but when you map something like a ComboBox subclass to a field the Width probably shouldn't be adjusted.
If you leave the controls selected, you can rightclick the Height on the property sheet and select Reset To Default for all the controls at once, but doing so to the Width loses some of the work VFP did for you.
I wrote this little builder to fix things back the way they should be.
* ResetSize.prg 14-May-98
* this function restores control height and widths to default
* because drag and drop from the PM overrides them
PARAMETERS uP1, uP2, uP3 && builders get sent 3 parameters by builder.app
n = aselobj( laObjects )
for i = 1 to n
if ( type( "laObjects[i].Height" ) != "U" )
laObjects[i].ResetToDefault( "Height" )
endif
if ( ( type( "laObjects[i].Width" ) != "U" ) and ;
( laObjects[i].BaseClass != "Textbox" ) )
laObjects[i].ResetToDefault( "Width" )
endif
endfor
To register this as a builder on the context menu in the designers:
use home()+"wizards\builder.dbf"
insert into builder values ("FieldMap Reset Height/Width", ;
"Fix the Height and Width of field mapped controls", ;
"", "MULTISELECT", "resetsize.prg", "", "", "" )
use