Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-access > #9385

Size of Access windows on dual monitors

From "Phil" <phil@stantonfamily.co.uk>
Newsgroups comp.databases.ms-access
Subject Size of Access windows on dual monitors
Date 2014-05-14 18:47 +0100
Organization Aioe.org NNTP Server
Message-ID <ll0a8g$rid$1@speranza.aioe.org> (permalink)

Show all headers | View raw


I have a dual monitor setup. And I want to get the size of the Access window
so that I can play around with form sizes & positions.

Sorry, this is a bit longwinded.

Option Compare Database
Option Explicit

    Private Type Rect
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type

Private vate Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long,
lpRect As Rect) As Long Private Declare Function MonitorFromWindow Lib
"User32.dll" _         (ByVal hWnd As Long, ByVal dwFlags As Long) As Long
    
Private Declare Function GetMonitorInfo Lib "User32.dll" Alias
"GetMonitorInfoW" _ (ByVal hMonitor As Long, ByVal lpMonitorInfo As Long) As
Long

    Dim AreaHeight As Integer
    Dim AreaWidth As Integer

Sub GetAccessWindowSize()

    Dim Rec As Rect
    
    GetWindowRect Application.hWndAccessApp, Rec
    AreaHeight = Rec.Bottom
    AreaWidth = Rec.Right
    
End Sub

This gets the Size of the Access Window (AreaWidth & AreaHeight) OK on my
right hand monitor and for a maximised Access window I get a size of 1928 *
1058. Odd as the correct resolution should be 1920 * 1080 but the difference
in height may be something to do with the Windows Task bar). If I drag Access
over to the left hand monitor (it’s a bit narrower) I get maximizes Access
window of 8 * 1058 Again Odd as the resolution should be 1680*1050: There is
no taskbar on this monitor) So it appears that the GetWindowRect
overestimates both width & height by 8, which can easily be compensated for.


Sub MonitorDetails()
    
        Dim hMonitor        As Long
        Dim MonitorInfo     As typMonitorInfo
        Dim apiReturnCode   As Long
        
        hMonitor = MonitorFromWindow(Application.hWndAccessApp, &H0&)
        MonitorInfo.cbSize = LenB(MonitorInfo)
        
        apiReturnCode = GetMonitorInfo(hMonitor, VarPtr(MonitorInfo))
        
        With MonitorInfo.rcMonitor
            Debug.Print "Horizontal resolution: " & .Right - .Left
            Debug.Print "Vertical resolution: " & .Bottom - .Top
Debug.Print Debug.Print "Form Left: " & Me.WindowLeft & " Form width: " &
Me.WindowWidth         End With
    
    End Sub

This returns the resolutions correctly as either 1920 * 1080 or 1680 * 1050
depending on which monitor the form gets opened on.

So what I want is to get the correct width of the Access Window on the
smaller left hand screen.

Any ideas please?

Phil


---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Back to comp.databases.ms-access | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Size of Access windows on dual monitors "Phil" <phil@stantonfamily.co.uk> - 2014-05-14 18:47 +0100
  Re: Size of Access windows on dual monitors Patrick Finucane <patrickfinucanetx@gmail.com> - 2014-05-14 13:56 -0700
    Re: Size of Access windows on dual monitors "Phil" <phil@stantonfamily.co.uk> - 2014-05-15 22:42 +0100
      Re: Size of Access windows on dual monitors DFS <nospam@dfs.com> - 2014-05-15 23:33 -0400
        Re: Size of Access windows on dual monitors "Phil" <phil@stantonfamily.co.uk> - 2014-05-16 08:09 +0100
  Re: Size of Access windows on dual monitors Ulrich Möller <knobbi38@usenet.arcornews.de> - 2014-05-16 12:02 +0200

csiph-web