Search code examples
vb6multiple-monitors

how to Get the Dual Monitor is available or Get the Full Width including Dual Monitor in VB6


I am facing an issue with Dual Monitors in VB6, Please help me to find out the any one the following.

  1. Either get the Dual Monitor is connected or not?
  2. Get the Full Width of Screen (Primary Screen + Extended Monitor Screen)

Currently I am using the existing Properties available in VB6.

Screen.Width & Screen.Height which gives me only the Primary Monitor's Width and Height.


Solution

  • You'll have to use Windows API to determine the virtual screen size for a multi-monitor setup:

    Private Const SM_CXVIRTUALSCREEN = 78
    Private Const SM_CYVIRTUALSCREEN = 79
    Private Const SM_CMONITORS = 80
    Private Const SM_SAMEDISPLAYFORMAT = 81
    
    Private Declare Function GetSystemMetrics Lib "user32" ( _
       ByVal nIndex As Long) As Long
    
    Public Property Get VirtualScreenWidth() As Long
       VirtualScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN)
    End Property
    Public Property Get VirtualScreenHeight() As Long
       VirtualScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN)
    End Property
    Public Property Get DisplayMonitorCount() As Long
       DisplayMonitorCount = GetSystemMetrics(SM_CMONITORS)
    End Property
    Public Property Get AllMonitorsSame() As Long
       AllMonitorsSame = GetSystemMetrics(SM_SAMEDISPLAYFORMAT)
    End Property
    

    From vbAccelerator.com