Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Forms and screen resolution
Message
De
25/04/2009 08:02:57
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01396126
Message ID:
01396366
Vues:
191
Marcia, how would I save this as a .vcx to enable me to use it?

You create a form class using the form designer and name the class frmMaximize

You then add 2 custom properties:

WidthRatio
HeightRatio

and set them to 0

Add this code to the Init() of the form class:
     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
Add a custom method called ResizeControls to your form class and put the code below into it

>>
>>    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
>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform