Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Screen Resolution conflict
Message
De
01/01/2005 07:36:45
 
 
À
01/01/2005 05:20:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6
OS:
Windows '98
Network:
Windows 98
Database:
Visual FoxPro
Divers
Thread ID:
00973613
Message ID:
00973616
Vues:
41
When they run it then screen displays small. Is there any solution for resizing forms without rewriting codes for 800 x 600 resolution. I mean may be there any resize class.

Yhis should help get you started. Add a custom method called ResizeControls to your base form class. This code goes in the Init of your base 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	
This 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		
ENDCASE			
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform