ACC: How to Determine the Current Screen Resolution (95/97)

Last reviewed: August 28, 1997
Article ID: Q148395
The information in this article applies to:
  • Microsoft Access versions 7.0, 97

SUMMARY

Advanced: Requires expert coding, interoperability, and multi-user skills.

This article describes a sample user-defined Visual Basic for Applications function that you can use to determine the current screen resolution. This function is useful in determining if you are running in standard VGA mode (640 x 480) or Super VGA mode (800 x 600 or 1024 x 768).

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.

MORE INFORMATION

The following example demonstrates how to create and use the sample GetScreenResolution() function.

NOTE: You may have some Microsoft Windows API functions defined in an existing Microsoft Access library; therefore, your declarations may be duplicates. If you receive a duplicate procedure name error message, remove or comment out the declarations statement in your code.

  1. Create a new module, and type the following Declarations and function:

          '*****************************************************************
          ' DECLARATIONS SECTION
          '*****************************************************************
    

          Option Explicit
    

          Type RECT
    
              x1 As Long
              y1 As Long
              x2 As Long
              y2 As Long
          End Type
    
          ' NOTE: The following declare statements are case sensitive.
    
          Declare Function GetDesktopWindow Lib "User32" () As Long
          Declare Function GetWindowRect Lib "User32" _
             (ByVal hWnd As Long, rectangle As RECT) As Long
    
          '*****************************************************************
          ' FUNCTION: GetScreenResolution()
          '
          ' PURPOSE:
          '   To determine the current screen size or resolution.
          '
          ' RETURN:
          '   The current screen resolution. Typically one of the following:
          '      640 x 480
          '      800 x 600
          '      1024 x 768
          '
          '*****************************************************************
          Function GetScreenResolution () as String
              Dim R As RECT
              Dim hWnd As Long
              Dim RetVal As Long
              hWnd = GetDesktopWindow()
              RetVal = GetWindowRect(hWnd, R)
              GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)
          End Function
    
    

  2. On the View menu, click Debug window.

  3. Type the following line in the Debug window, and then press ENTER:

          ? GetScreenResolution()
    

    Note that the current screen resolution is displayed in the Debug window. If the current resolution is standard VGA, the following is displayed in the Debug window:

          640x480
    

REFERENCES

For more information about how to determine the current screen resolution in Microsoft Access 2.0, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q113458
   TITLE     : ACC2: How to Determine the Current Screen Resolution (2.0)

For more information about API Calls, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q147781
   TITLE     : How to convert API calls from 16-bit to 32-bit.
Keywords          : kbprg PgmApi PgmHowTo
Version           : 7.0 97
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: August 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.