Microsoft KB Archive/148856

= ACC: How to Position Microsoft Access on the Screen (95/97) =

Article ID: 148856

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q148856



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

To position Microsoft Access on the screen, you need to call the SetWindowPos Windows API function. This article shows you how to call this function to position Microsoft Access on the screen.

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
To position Microsoft Access on the screen, use the SetWindowPos application programming interface (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.

 Open or create a new module in Microsoft Access.  Within the Declarations section, add the following declares, constants, and comments: '====================================     ' 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&)

Global Const HWND_TOP = 0           'Moves MS Access window to top 'of Z-order.

'Values for wFlags.

Global Const SWP_NOZORDER = &H4     'Ignores the hWndInsertAfter.   Type the following function: Function SizeAccess Dim cX As Long, cY As Long, cHeight As Long Dim cWidth As Long, h As Long 'Get handle to Microsoft Access. h = Application.hWndAccessApp

cX = 0 cY = 0 cWidth = 640 cHeight = 480

'Position Microsoft Access. SetWindowPos h, HWND_TOP, cX, cY, cWidth, cHeight, SWP_NOZORDER

End Function 

