ACC2: How to Dynamically Size Forms to Fit Screen Resolution

ID: Q138901


The information in this article applies to:


SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

Microsoft Access provides no built in support to scale a form's size to match the current screen resolution. A form that you design on a computer with a video driver resolution of 1024x768 (Super VGA) may appear too large on computers running at 640x480 (VGA) resolution. A form that you design using 640x480 resolution may appear too small on computers running at 1024x768 resolution.

The following information describes where you can obtain two Access Basic functions, glrScaleForm() and glrResizeForm(), that you can use to dynamically scale and size a form. The glrScaleForm() function can be called from the Open event of your form to scale the size of a form to the current screen resolution when the form loads. The glrResizeForm() can be called from the Resize event of the form to automatically move and size the contents of a form proportionally to fit the new dimensions of the form window.


MORE INFORMATION

glrScaleForm()

The glrScaleForm() function can be called from the Open event of your form to automatically scale the form to the current screen resolution.

   Syntax:

      Function glrScaleForm (frm As Form, intX As Integer, intY As Integer)

      frm:  form to be scaled
      intX: horizontal resolution at which the form was designed
      intY: vertical resolution at which the form was designed

   Example:

      Sub Form_Open (Cancel As Integer)
         Dim RetVal
         RetVal = glrScaleForm(Me, 1024, 768)
      End Sub 

glrResizeForm()

The glrResizeForm() function can be called from the Resize event of your form to automatically move and resize the contents proportionally to fit within the new form window size.

   Syntax:

      Function glrResizeForm (frm As Form, fDoResize As Variant)

      frm:       form to resized
      fDoResize: boolean value indicating if the form should be resized or
                 the information tracked

   Example:

      Sub Form_Resize ()
         Dim RetVal
         RetVal = glrResizeForm(Me, True)
      End Sub 

How To Obtain The glrScaleForm And glrResizeForm Functions

The glrScaleForm() and glrResizeForm() functions, written by Ken Getz, are published in the following book:

   Microsoft Access 2 Developer's Handbook. Ken Getz, Paul Litwin,
   Greg Reddick. Sybex: 1994 ISBN: 0-7821-1327-3 

Discussion of these function begins on page 506, chapter 8, "Screen Resolution and Distributing Forms." The functions are included in the file _Glrfile.exe on the accompanying companion disk. This self-extracting, compressed file contains the file _Chapter.exe, another self-extracting, compressed file, which contains the database CH8.mdb. The form frmTest1280x1024 in CH8.mdb demonstrates the use of these functions. Check the "Enable Automatic Resizing?" check box in the upper-left corner of the form frmTest1280x1024, and then resize the form window to see the glrResizeForm() function work.

These functions were originally published with a column in Smart Access magazine.

   "Create Resolution-Independent Forms in Access 2.0" by Ken Getz
   Smart Access, June 1994 

Smart Access, published monthly, is a newsletter aimed at Microsoft Access developers. It is published by Pinnacle Publishing.

   Pinnacle Publishing, Inc.
   18000 72nd Ave South, Suite 217
   Kent, WA 98032
   800-788-1900 

The products discussed here are manufactured by vendors independent of Microsoft; we make no warranty, implied or otherwise, regarding these products' performance or reliability.

Additional query words:


Keywords          : kb3rdparty FmsHowto 
Version           : WINDOWS:2.0
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: June 14, 1999