>>************************************************** >>*-- Class: frmmaximize >>*-- ParentClass: form >>*-- Self maximizing form for sovereign applications >>* >> >>oform1=CREATEOBJECT("fmax") >>susp >>oform1.Show() >> >> >>Define Class fmax As Form >> DoCreate = .T. >> *-- SYSMETRIC( 1 ) / 640 >> widthratio = 0 >> *-- SYSMETRIC( 2 ) / 480 >> heightratio = 0 >> Name = "fmax" >> >> >> >> >> *-- 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 >