ACC2: How to Dynamically Size Forms to Fit Screen Resolution

Last reviewed: April 21, 1997
Article ID: Q138901
The information in this article applies to:
  • Microsoft Access version 2.0

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 hand 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.


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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 21, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.