Rick,
Using the VB Sample Monitor.exe you told me about seems to have a problem.
It successfully knows I have two Monitors.
It successfully returns the virtual desktop.
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 you? And if so do you have any ideas why
it wouldn't work for me.
This function always returns a 0.
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)
GetMonitorFromWindow = lReturn
Exit Function
GetMonitorFromWindow_Err:
If Err.Number = 453 Then
'Non-Multimonitor OS, return -1
GetMonitorFromWindow = -1
End If
End Function
Thanks
Ken
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:h-********************@comcast.com...
How can I detect if the user has dual monitors and then how do I control
which monitor a form is displayed on. Currently my forms always come up on my right monitor. What if I want to have it always display on my left
one?
You may find the following of some help -- go to your VB Help Files,
select the Search tab (note I said SEARCH tab) and type in
SAMPLE: MULTIMON.EXE
or possibly
FILE: MULTIMON.EXE
depending on the version of your VB Help files. Anyway, select the first
listed article (at least its the first one on my system); it will start
with whichever of the above search strings you used. This gives you some
information and a link to download a heavily commented VB project called
Multimon.exe.
Rick - MVP