ðHgeocities.com/Heartland/Pond/4805/API7.htmgeocities.com/Heartland/Pond/4805/API7.htm.delayedx¹PÔJÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈЮìÄ@OKtext/html€çhÄ@ÿÿÿÿb‰.HSun, 20 Jan 2002 12:59:34 GMT:Mozilla/4.5 (compatible; HTTrack 3.0x; Windows 98)en, *¸PÔJÄ@ ACC2000: How to Position and Size Microsoft Access on the Screen

ACC2000: How to Position and Size Microsoft Access on the Screen


The information in this article applies to:


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

This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).

SUMMARY

To position Microsoft Access on the screen, you need to call the SetWindowPos() Windows API function. This article demonstrates how to call this function to position and size Microsoft Access on the screen.

 

MORE INFORMATION

To position Microsoft Access on the screen, use the SetWindowPos() API function included in the User32.dll dynamic-link library (DLL) included with Windows. To do so, follow these steps:

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. Start Microsoft Access, and then open any database file or a project file.
  2. Create a new module.
  3. Type or paste the following code in the module:
'====================================
' Global Declarations
'====================================
 
Option Compare Database
Option Explicit
 
'NOTE: The following "Declare" statement is case sensitive.
 
Declare Sub SetWindowPos Lib "User32" (ByVal hWnd&, _
                           ByVal hWndInsertAfter&, _
                           ByVal X&, ByVal Y&, ByVal cX&, _
                           ByVal cY&, ByVal wFlags&)
 
'Moves MS Access window to top of Z-order.
Global Const HWND_TOP = 0
 
'Values for wFlags.
Global Const SWP_NOZORDER = &H4      'Ignores the hWndInsertAfter.
 
Function SizeAccess(cX As Long, cY As Long, _
  cHeight As Long, cWidth As Long)
 
   Dim h As Long
   'Get handle to Microsoft Access.
   h = Application.hWndAccessApp
 
   'Position Microsoft Access.
   SetWindowPos h, HWND_TOP, cX, cY, cWidth, _
   cHeight, SWP_NOZORDER
 
End Function
 
 
  1. Open the Immediate window, and then type the sample command below. This example sets both X and Y to 0, sets the width to 480, and sets the height to 640.

?SizeAccess(0,0,480,640)

  1. Press ENTER, and then return to the Access window.

Note that the position and size of the Access window has changed to reflect the values assigned to cX, cY, cWidth, and cHeight variables.

Additional query words: api resize size