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


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

Size of Access windows on dual monitors

Started by"Phil" <phil@stantonfamily.co.uk>
First post2014-05-14 18:47 +0100
Last post2014-05-16 12:02 +0200
Articles 6 — 4 participants

Back to article view | Back to comp.databases.ms-access


Contents

  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

#9385 — Size of Access windows on dual monitors

From"Phil" <phil@stantonfamily.co.uk>
Date2014-05-14 18:47 +0100
SubjectSize of Access windows on dual monitors
Message-ID<ll0a8g$rid$1@speranza.aioe.org>
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

[toc] | [next] | [standalone]


#9388

FromPatrick Finucane <patrickfinucanetx@gmail.com>
Date2014-05-14 13:56 -0700
Message-ID<4c775000-4d71-46a6-a299-e7eb85866aa4@googlegroups.com>
In reply to#9385
On Wednesday, May 14, 2014 12:47:58 PM UTC-5, Phil wrote:
> 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

I saw some API functions; EnumDisplayMonitors and GetMonitorInfo, but the functions were written in c++. not vba.  Somehow you need the hwnd value for each monitor. Wish I could help.

[toc] | [prev] | [next] | [standalone]


#9402

From"Phil" <phil@stantonfamily.co.uk>
Date2014-05-15 22:42 +0100
Message-ID<ll3cce$nqb$1@speranza.aioe.org>
In reply to#9388
On 14/05/2014 21:56:26, Patrick Finucane wrote:
> On Wednesday, May 14, 2014 12:47:58 PM UTC-5, Phil wrote:
>> I have a dual monitor setup. And I want to get the size of the Access win
> dow 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 Funct ion GetMonitorInfo Lib "User32.dll" Alias
> "GetMonitorInfoW" _ (ByVal hMonit or As Long, ByVal lpMonitorInfo As Long)
> As Long Dim AreaHeight As Integer Dim AreaWidth As Integer Sub
> GetAccessWindowSize() Dim Rec As Rect GetWindo wRect
> 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 T ask bar). If I drag Access over to the left hand monitor (it's a
> bit narrow er) I get maximizes Access window of 8 * 1058 Again Odd as the
> resolution s hould 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 MonitorI nfo As typMonitorInfo Dim apiReturnCode As Long hMonitor
> = MonitorFromWin dow(Application.hWndAccessApp, &H0&) MonitorInfo.cbSize =
> LenB(MonitorInf o) apiReturnCode = GetMonitorInfo(hMonitor,
> VarPtr(MonitorInfo)) With Mon itorInfo.rcMonitor Debug.Print "Horizontal
> resolution: " & .Right - .Left D ebug.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 168 0 * 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 malw are
> because avast! Antivirus protection is active. http://www.avast.com I saw
> some API functions; EnumDisplayMonitors and GetMonitorInfo, but the f
> unctions were written in c++. not vba. Somehow you need the hwnd value for
> each monitor. Wish I could help.
> 

Thanks Patrick

I have an enormouse API database probably about 500 APIs with parameters,
notes and most importantly examples all written in VBA Have found some
examples on monitors and will ltake it from there

Phil

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

[toc] | [prev] | [next] | [standalone]


#9403

FromDFS <nospam@dfs.com>
Date2014-05-15 23:33 -0400
Message-ID<ll40ue$col$3@dont-email.me>
In reply to#9402
On 05/15/2014 05:42 PM, Phil wrote:


> I have an enormouse API database probably about 500 APIs with parameters,
> notes and most importantly examples all written in VBA Have found some
> examples on monitors and will ltake it from there


Any chance you could share that API with the group?

[toc] | [prev] | [next] | [standalone]


#9404

From"Phil" <phil@stantonfamily.co.uk>
Date2014-05-16 08:09 +0100
Message-ID<ll4diq$of2$1@speranza.aioe.org>
In reply to#9403
On 16/05/2014 04:33:36, DFS wrote:
> On 05/15/2014 05:42 PM, Phil wrote:
> 
> 
>> I have an enormouse API database probably about 500 APIs with parameters,
>> notes and most importantly examples all written in VBA Have found some
>> examples on monitors and will ltake it from there
> 
> 
> Any chance you could share that API with the group?
> 
> 
> 

Sorry, I got it wrong. 925 APIs, not the 500 I mentioned

See API-Guide 3.7 at

http://softadvice.informer.com/Api-guide_3.7.html 
which should down load agsetup.exe

Phil

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

[toc] | [prev] | [next] | [standalone]


#9405

FromUlrich Möller <knobbi38@usenet.arcornews.de>
Date2014-05-16 12:02 +0200
Message-ID<ll4nn3$8gj$1@dont-email.me>
In reply to#9385
Am 14.05.2014 19:47, schrieb Phil:
> 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
>
Hi Phil,

perhaps this article give you some hints for solving your problem: 
http://www.vbaccelerator.com/home/VB/Tips/Working_with_Multiple_Monitors/article.asp.

Ulrich

[toc] | [prev] | [standalone]


Back to top | Article view | comp.databases.ms-access


csiph-web