ACC: How to Determine the Current Screen Resolution (1.x/2.0)

ID: Q113458


The information in this article applies to:


SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

This article describes a sample user-defined Access Basic 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 Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information on Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x, or the "Building Applications" manual in version 2.0.


MORE INFORMATION

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

Notes:

  1. Create a new module, and type the following Declarations and function:
    
          '
          *****************************************************************
          ' DECLARATIONS SECTION
    
          Option Explicit
    
          Type RECT
              x1 As Integer
              y1 As Integer
              x2 As Integer
              y2 As Integer
          End Type
    
          Declare Function GetDesktopWindow Lib "User" () As Integer
          Declare Function GetWindowRect Lib "User" _
             (ByVal hWnd As Integer, rectangle As RECT) As Integer
    
          '
          *****************************************************************
          ' 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 Integer
              Dim RetVal As Integer
              hWnd = GetDesktopWindow()
              RetVal = GetWindowRect(hWnd, R)
              GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)
          End Function 


  2. From the View menu, choose Immediate Window.


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

    ? GetScreenResolution()


The current screen resolution will be displayed in the Immediate window. If the current resolution is standard VGA, the following will be displayed in the Immediate window:

   640x480 


REFERENCES

For an example of how to determine the current screen resolution in Microsoft Access 95 and 97, please see the following article here in the Microsoft Knowledge Base:

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


Keywords          : kbprg 
Version           : 1.0 1.1 2.0
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: April 2, 1999