LOCAL loControl WITH Thisform *** Determine the ratio needed to maximize the form *** depending on screen resolution and store it to form properties .WidthRatio = SYSMETRIC( 1 ) / 640 .HeightRatio = SYSMETRIC( 2 ) / 480 *** If resolution is higher than 640 x 480, reposition *** and maximize the form IF .WidthRatio > 1 .Top = 0 .Left = 0 .Width = .Width * .WidthRatio .Height = .Height * .HeightRatio *** And resize each control contained in the form FOR EACH loControl IN .Controls .ResizeControls( loControl ) ENDFOR ENDIF ENDWITHThis code in ResizeControls:
LPARAMETERS toControl LOCAL loPage, loControl, loColumn, lnColumnWidths[1], lnCol IF PEMSTATUS( toControl, 'Width', 5 ) toControl.Width = toControl.Width * Thisform.WidthRatio ENDIF IF PEMSTATUS( toControl, 'Height', 5 ) toControl.Height = toControl.Height * Thisform.HeightRatio ENDIF IF PEMSTATUS( toControl, 'Top', 5 ) toControl.Top = toControl.Top * Thisform.HeightRatio ENDIF IF PEMSTATUS( toControl, 'Left', 5 ) toControl.Left = toControl.Left * Thisform.HeightRatio ENDIF *** Now resize the font of the control, grid (naturally <g>) is a special case because *** resizing the font resizes the column widths of the grid, so save and restore them IF UPPER( ALLTRIM( toControl.Baseclass ) ) = 'GRID' DIMENSION lnColumnWidths[toControl.ColumnCount] FOR lnCol = 1 TO toControl.ColumnCount lnColumnWidths[lnCol] = toControl.Columns[lnCol].Width ENDFOR toControl.Fontsize = INT( toControl.FontSize * Thisform.WidthRatio ) FOR lnCol = 1 TO toControl.ColumnCount toControl.Columns[lnCol].Width = lnColumnWidths[lnCol] ENDFOR ELSE IF PEMSTATUS( toControl, 'Fontsize', 5 ) toControl.Fontsize = INT( toControl.FontSize * Thisform.WidthRatio ) ENDIF ENDIF DO CASE CASE UPPER( toControl.BaseClass ) = 'PAGEFRAME' FOR EACH loPage IN toControl.Pages Thisform.ResizeControls( loPage ) ENDFOR CASE INLIST( UPPER( toControl.BaseClass ), 'PAGE', 'CONTAINER' ) FOR EACH loControl IN toControl.Controls Thisform.ResizeControls( loControl ) ENDFOR CASE UPPER( toControl.BaseClass ) = 'GRID' WITH toControl .RowHeight = .RowHeight * Thisform.HeightRatio .HeaderHeight = .HeaderHeight * Thisform.HeightRatio FOR EACH loColumn IN .Columns loColumn.Width = loColumn.Width * Thisform.WidthRatio ENDFOR ENDWITH CASE INLIST( UPPER( toControl.BaseClass ), 'COMBOBOX', 'LISTBOX' ) LOCAL lnCol, lnStart, lnEnd, lnLen, lcColumnWidths WITH toControl IF .ColumnCount < 2 .ColumnWidths = ALLTRIM( STR( .Width ) ) ELSE lcColumnWidths = '' lnStart = 1 FOR lnCol = 1 TO .ColumnCount - 1 lnEnd = AT( ',', .ColumnWidths, lnCol ) lnLen = lnEnd - lnStart lcColumnWidths = lcColumnWidths + IIF( EMPTY( lcColumnWidths ), '', ',' ) + ALLTRIM( STR( VAL (SUBSTR( .ColumnWidths, lnStart, lnLen ) ) * Thisform.WidthRatio ) ) lnStart = lnEnd + 1 ENDFOR lnLen = LEN( .ColumnWidths ) - lnStart + 1 lcColumnWidths = lcColumnWidths + ',' + ALLTRIM( STR( VAL (SUBSTR( .ColumnWidths, lnStart, lnLen ) ) * Thisform.WidthRatio ) ) .ColumnWidths = lcColumnWidths ENDIF ENDWITH CASE INLIST( UPPER( ALLTRIM( toControl.BaseClass ) ), 'COMMANDGROUP', 'OPTIONGROUP' ) LOCAL lnButton FOR lnButton = 1 TO toControl.ButtonCount ThisForm.resizeControls( toControl.Buttons[lnButton] ) ENDFOR OTHERWISE *** There is no otherwise...I think we got all cases ENDCASEMarcia