The information in this article applies to:
- Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0
   
 SUMMARY
 
Screens developed under one resolution may not look the way you want them
to look when you run the screens on systems with different screen
resolutions. One solution is to develop several different screens under
different resolutions, and run the screen that is the same as the current
resolution. However, in Visual FoxPro it is possible to dynamically resize
the screen and reposition objects on it based on the current resolution.
This article shows by example how to do this.
 
 MORE INFORMATION
 
 Step-by-Step Example
 
- Create a new form while under 640x480 resolution. Add some controls
   such as text boxes, command buttons, and labels to the form.
 - Place the following code in the Init event of the form and in the Init
   event of any container objects such as a page on a pageframe that are
   on the form:
       ** Assumes a screen built at 640x480
      Local lnHeight, lnWidth, lnHeightdiff, lnWidthdiff
      lnHeight=640 && The height of the original resolution
      lnWidth=480 && The width of the original resolution
      lnHeightdiff=0 && Variable to hold the height difference
      lnWidthdiff=0 && Variable to hold the width difference
      IF SYSMETRIC(1)<>lnHeight && If this is not 640x480 resolution
         lnHeightdiff=SYSMETRIC(1)/lnHeight
         lnWidthdiff=SYSMETRIC(2)/lnWidth
      ** You need to remark out the next four lines of code if this is
      ** in the Init of a container object such as a page on a pageframe,
      ** or any other non-form container object that has a Controls and
      ** ControlsCount property.
      THIS.Height=THIS.height*lnHeightdiff
      THIS.Width=THIS.Width*lnWidthdiff
      THIS.Top=THIS.Top*lnHeightdiff
      THIS.Left=THIS.Left*lnHeightDiff
      ** The code goes through each object, resizes and
      ** repositions it.
      FOR i = 1 to THIS.ControlCount
         WITH THIS.controls(i)
            .Height=.Height*lnHeightdiff
            .Width=.Width*lnWidthdiff
            .Top=.Top*lnHeightdiff
            .Left=.Left*lnWidthdiff
      ** You could also resize the font at this point
      ** by changing the FontSize property, perhaps to
      **IF TYPE(".FontSize") # "U"
      **    && The IF ensures the control has a FontSize property
      ** .FontSize=.Fontsize*((.5*lnWidthdiff)+(.5*lnHieghtdiff))
      **ENDIF
      ** However, some higher screen resolutions can change
      ** the appearance of fonts considerably, so testing is
      ** advised before trying that step.
            ENDWITH
         ENDFOR
      ENDIF
      THISFORM.Refresh
 - Run the form in a different resolution. Observe the automatic changes
   that are made.
  
 REFERENCES
 
For more information about working with multiple screen resolutions,
please see the following article in the Microsoft Knowledge Base:
 
    ARTICLE-ID: Q114668
   TITLE     : Using Multiple Screen Resolutions in FoxPro for Windows
 
	
	 |