Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Different Screen Resolutions
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00294704
Message ID:
00295231
Vues:
21
Hi Alan.

>>Most of our PCs are running in 640x480 mode and I develop in 640x480. One or two of our PCs are running 600x800. What’s the best way to reposition the form and controls to adjust for the higher resolution? <<

All philosopical issues aside, put this code in the init of your base form class:
LOCAL loControl
#DEFINE WIDTHRATIO SYSMETRIC( 1 ) / 640
#DEFINE HEIGHTRATIO SYSMETRIC( 2 ) / 480

IF WIDTHRATIO > 1
  WITH Thisform
    .Top = 0
    .Left = 0
    .Width = .Width * WIDTHRATIO
    .Height = .Height * HEIGHTRATIO
  ENDWITH
  FOR EACH loControl IN Thisform.Controls
    Thisform.ResizeControls( loControl )
  ENDFOR
ENDIF	
And this code goes in ResizeControls:
LPARAMETERS toControl
LOCAL loPage, loControl, loColumn, lnColumnWidths[1], lnCol

#DEFINE WIDTHRATIO SYSMETRIC( 1 ) / 640
#DEFINE HEIGHTRATIO SYSMETRIC( 2 ) / 480

IF PEMSTATUS( toControl, 'Width', 5 )
  toControl.Width = toControl.Width * WIDTHRATIO
ENDIF	
IF PEMSTATUS( toControl, 'Height', 5 )
  toControl.Height = toControl.Height * HEIGHTRATIO
ENDIF
IF PEMSTATUS( toControl, 'Top', 5 )
  toControl.Top = toControl.Top * HEIGHTRATIO
ENDIF
IF PEMSTATUS( toControl, 'Left', 5 )
  toControl.Left = toControl.Left * 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 * 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 * 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 * HEIGHTRATIO
      .HeaderHeight = .HeaderHeight * HEIGHTRATIO
      FOR EACH loColumn IN .Columns
        loColumn.Width = loColumn.Width * 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 ) ) * WIDTHRATIO ) )
	  lnStart = lnEnd + 1
	ENDFOR		
	lnLen = LEN( .ColumnWidths ) - lnStart + 1
	lcColumnWidths = lcColumnWidths + ',' + ALLTRIM( STR( VAL (SUBSTR( .ColumnWidths, lnStart, lnLen ) ) * 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			
Marcia
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform