Help and Support
 

powered byLive Search

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

Retired KB ArticleThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Article ID:113458
Last Review:May 6, 2003
Revision:2.0
This article was previously published under Q113458

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.

Back to the top

MORE INFORMATION

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

Notes:
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.
In the following sample code, an underscore (_) is used as a line- continuation character. Remove the underscores when re-creating this code in Access Basic.
In Microsoft Access version 2.0, you can create code in a form module. Code in a form module is restricted to that form. The Type statement used in this example must be global. You can use this code in a form's module if the Type statement is in the Declarations section of a global Access Basic module. For more information about the Type statement, search for "type" then "Type Statement" using the Microsoft Access Help menu.
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
				

Back to the top

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:

148395 (http://support.microsoft.com/kb/148395/EN-US/) ACC: How to Determine the Current Screen Resolution (95/97)

Back to the top


APPLIES TO
Microsoft Access 1.0 Standard Edition
Microsoft Access 1.1 Standard Edition
Microsoft Access 2.0 Standard Edition

Back to the top

Keywords: 
kbhowto kbprogramming KB113458

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by E-mail, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.