Slight mod of this should do it
Public Const WU_SW_RESTORE = 9
Public Const WU_SW_MAXIMIZE = 3
Public Const WU_SW_MINIMIZE = 2
Public Const WU_SW_SHOWNORMAL = 1
Public Const WU_SW_HIDE = 0
Public Type WU_RECT
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type
Public Declare Function IsZoomed Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function MoveWindow Lib "user32" (ByVal hWnd As Long, ByVal X As Long, ByVal Y As Long, ByVal dx As Long, ByVal dy As Long, ByVal fRepaint As Long) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal NewState As Long) As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, R As WU_RECT) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Function SetAccessSize(Optional ByVal dx As Long = 1024, Optional ByVal dy As Long = 768) As Long
' Set Size of Access & Center on Screen
Const X = 0, Y = 0
Dim hWnd As Long, F As Long
Dim RDesk As WU_RECT
On Local Error Resume Next
hWnd = Application.hWndAccessApp
If (IsZoomed(hWnd)) Then
ShowWindow hWnd, WU_SW_RESTORE
End If
GetWindowRect GetDesktopWindow(), RDesk
If ((RDesk.x2 - RDesk.x1) - (dx - X) < 0) Or ((RDesk.y2 - RDesk.y1) - (dy - Y)) < 0 Then
' Screen Size To Small
MoveWindow hWnd, RDesk.x1, RDesk.y1, RDesk.x2, RDesk.y2, True
F = False
Else
MoveWindow hWnd, RDesk.x1 + ((RDesk.x2 - RDesk.x1) - dx) / 2, RDesk.y1 + ((RDesk.y2 - RDesk.y1) - dy) / 2, dx, dy, True
F = True
End If
SetAccessSize = F
End Function
Pieter
Hello!
Is there a way to get the main Access window's position and size compared to the screen display?
Thanks in advance for any suggestion.