Dual Monitor Support

Dual Monitor Support

Post by KJM » Wed, 25 Jun 2003 18:56:55



Hi    ,

Using the VB Sample Monitor.exe as found when searching VB Help for "SAMPLE:
MULTIMON.EXE" seems to have a problem.

The program successfully knows I have two Monitors and successfully returns
the virtual desktop size.

But, the function GetMonitorFromWindow() always returns a 0 which then
causes the
two buttons "Where is the Monitor I'm On?" and  "Center this Form on the
Current Monitor" to always use my left Primary Monitor.

I was wondering if this works for anyone else?  And if so do you have any
ideas why
it wouldn't work for me.

This function always returns a 0.  I'm using VB6.

Public Function GetMonitorFromWindow(hwnd As Long, dwFlags As Long) As Long
    '=====================================================
    'Returns a monitor handle that the Window (hwnd) is in
    '=====================================================
    Dim lReturn As Long

    On Error GoTo GetMonitorFromWindow_Err
    lReturn = MonitorFromWindow(hwnd, dwFlags)   '<<<< always returns a 0
    GetMonitorFromWindow = lReturn
    Exit Function
GetMonitorFromWindow_Err:
    If Err.Number = 453 Then
        'Non-Multimonitor OS, return -1
        GetMonitorFromWindow = -1
    End If
End Function

Thanks
Ken

 
 
 

Dual Monitor Support

Post by Mike D Sutto » Thu, 26 Jun 2003 07:54:32


Quote:> Using the VB Sample Monitor.exe as found when searching VB Help for
"SAMPLE:
> MULTIMON.EXE" seems to have a problem.

> The program successfully knows I have two Monitors and successfully
returns
> the virtual desktop size.

> But, the function GetMonitorFromWindow() always returns a 0 which then
> causes the
> two buttons "Where is the Monitor I'm On?" and  "Center this Form on the
> Current Monitor" to always use my left Primary Monitor.

> I was wondering if this works for anyone else?  And if so do you have any
> ideas why
> it wouldn't work for me.

> This function always returns a 0.  I'm using VB6.

Check your declares are correct for a start:

'***
Private Declare Function MonitorFromWindow Lib "User32.dll" _
    (ByVal hWnd As Long, ByVal dwFlags As Long) As Long  ' HMONITOR

Private Const MONITOR_DEFAULTTONULL As Long = &H0
Private Const MONITOR_DEFAULTTOPRIMARY As Long = &H1
Private Const MONITOR_DEFAULTTONEAREST As Long = &H2
'***

Since you're passing 0 as the last parameter, if the window is not on any
monitor it will return you 0 - Try using MONITOR_DEFAULTTONEAREST here
instead and see if that give you any better results.  Presumably the monitor
is attached to the desktop?  If not then you may get unpredictable results
but I've never tested this before.  You can test to make sure it is with the
EnumDisplayDevices() API call, and check for the
DISPLAY_DEVICE_ATTACHED_TO_DESKTOP flag.
Finally, make sure you're passing it a valid window handle, you can check
this with the IsWindow() API call.
Hope this helps,

    Mike

 - Microsoft Visual Basic MVP -

WWW: Http://www.mvps.org/EDais/

 
 
 

1. Dual Monitor Support

For info: Tridium Research in Washington now has NT drivers for the Duographics
ISA card that allows you to use two monitors at the same time. I love the
freedom this card gives me to have an animation go horizontally across twice
the usual single monitor real estate. It is also just great to keep an incoming
email screen/stock quote screen on one monitor and use the other monitor for
whatever real work I am doing. I have the 4 meg version at a retail price of
$700 and there are 1 and 2 meg versions for less money. You have to have at
least 32 Megs of RAM in your PC to run two screens simultaneously!

Call Tridium (next door to Microsoft) at 425-820-8810 for more info or email

2. Virtual Pet

3. Dual monitor support

4. SMALLER JPEGs

5. Computer Graphics Contests

6. Win98, WinNT5, Dual monitor support and AGP

7. Subclass MS TabStrip Control...

8. MAYA and dual monitor support,which graphics Card

9. Dual Monitor Support

10. dual monitor support with low end open gl card?

11. Does 3dsmax support dual monitors

12. Adding a PCI card to support dual monitor