************************************************** *-- Class: frmmaximize *-- ParentClass: form *-- BaseClass: form *-- Self maximizing form for sovereign applications * DEFINE CLASS frmmaximize AS FORM *-- SYSMETRIC( 1 ) / 640 widthratio = 0 *-- SYSMETRIC( 2 ) / 480 heightratio = 0 NAME = "frmmaximize" *-- Drill down into pageframes, pages, grids, etc on the form and resize all of the controls PROCEDURE 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 ENDCASE ENDPROC PROCEDURE INIT 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 ENDWITH ENDPROC ENDDEFINE