ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   one or two monitors (https://www.excelbanter.com/excel-programming/431167-one-two-monitors.html)

Robert Flanagan

one or two monitors
 
Is there any way to determine if a user is using two monitors?

Bob Flanagan



joel

one or two monitors
 
Yes. I finally got it to work with this webpage

http://www.xtremevbtalk.com/showthread.php?t=289231

Const MONITOR_DEFAULTTONULL As Long = 0
Const MONITOR_DEFAULTTOPRIMARY As Long = 1
Const MONITOR_DEFAULTTONEAREST As Long = 2

Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type

Type LPMONITORINFO
cbSize As Double
rcMonitor As RECT
rcWork As RECT
dwflags As Long
End Type


Private Declare Function GetNumberOfPhysicalMonitorsFromHMONITOR Lib
"dxva2.dll" _
(ByVal hmonitor As Long, ByRef pdwNumberOfPhysicalMonitors As
LPMONITORINFO) As Long

Private Declare Function MonitorFromWindow Lib "user32.dll" _
(ByVal hWind As Long, ByVal dwflags As Long) As Long


Sub test()
Dim hWind As Long
Dim hmonitor As Long
Dim flags As Long

Dim monInfo As LPMONITORINFO
hWind = Application.hwnd

A = Len(hWind)
flags = MONITOR_DEFAULTTOPRIMARY
monInfo.cbSize = Len(monInfo)

hmonitor = MonitorFromWindow(hWind, flags)

NumMonitors = GetNumberOfPhysicalMonitorsFromHMONITOR(hmonitor, monInfo)



End Sub




"Robert Flanagan" wrote:

Is there any way to determine if a user is using two monitors?

Bob Flanagan





All times are GMT +1. The time now is 08:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com