473,382 Members | 1,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Dual Monitor Support

KJM
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?

Thanks
Ken
Jul 17 '05 #1
10 30381
> 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
Jul 17 '05 #2
KJM
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

Jul 17 '05 #3
I'm afraid I can't help you beyond giving you the reference that I did. I
only have one monitor on my system. Perhaps someone with multiple monitors
will stop by this thread, download the Monitor.exe file and test that
function out for you.

Rick - MVP
"KJM" <k.***@cox.net> wrote in message
news:ca********************@news2.central.cox.net. ..
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


Jul 17 '05 #4

"KJM" <k.***@cox.net> skrev i meddelandet
news:Q7*********************@news2.central.cox.net ...
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?

Use EnumDisplayMonitors to detect all monitors and get their resolution with
GetMonitorInfo. There is a good example in the API-guide showing how to do
this. It also shows how to use MonitorFromRect to determine on what monitor
a form is located.

I don't know how your monitors are setup. Is the right one your primary
monitor? If you want to place a form at Left = 200 on your secondary monitor
you must add the width of your primary monitor to the value. If the primary
has a resolution of 800x600 the value would be 1000.
It would be more natural to have your primary monitor to the left and your
secondary to the right since that's the way the "joined" desktop is
structured.
Jul 17 '05 #5
I don't know how I would survive with out my 2nd monitor, stepping
through the code from UI.exe to AX.DLL to AX.EXE on one screen scares
me (I would in fact like another)anyhow!(what you say you don't need
to step through yours)
It works correctly on my system (Win98 VB6 SP5).why you have the
problem is beyond me, maybe its down to your drivers.
Shame its a nice little gizzmo, keeps a class collection of the
monitors but if there are snags then it not too hot.I will look at it
a bit more given time but like I say though it all works fine here.
--
Geoff
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message news:<Ia********************@comcast.com>...
I'm afraid I can't help you beyond giving you the reference that I did. I
only have one monitor on my system. Perhaps someone with multiple monitors
will stop by this thread, download the Monitor.exe file and test that
function out for you.

Rick - MVP
"KJM" <k.***@cox.net> wrote in message
news:ca********************@news2.central.cox.net. ..
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.

Jul 17 '05 #6
KJM
Hi,

My left monitor is #1 and my right monitor is #2 when I click Identify in
Windows Screen Properties, Setting

All of my monitors are added to the monitors collection in the sample code.

The problem is the function call

lReturn = MonitorFromWindow(hwnd, dwFlags)

Always returns a zero so the sample always centers a form on my left #1
screen.

I use the Matrox Millennium G550 video card, Driver version 5.86.32.0, Two
monitors a 21" and a 19" both set to 1600 x 1200 resolution.

Thanks for your help
Ken
"B Pilgrim" <ex************@yahoo.se> wrote in message
news:%c*******************@newsb.telia.net...

"KJM" <k.***@cox.net> skrev i meddelandet
news:Q7*********************@news2.central.cox.net ...
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?

Use EnumDisplayMonitors to detect all monitors and get their resolution

with GetMonitorInfo. There is a good example in the API-guide showing how to do
this. It also shows how to use MonitorFromRect to determine on what monitor a form is located.

I don't know how your monitors are setup. Is the right one your primary
monitor? If you want to place a form at Left = 200 on your secondary monitor you must add the width of your primary monitor to the value. If the primary has a resolution of 800x600 the value would be 1000.
It would be more natural to have your primary monitor to the left and your
secondary to the right since that's the way the "joined" desktop is
structured.

Jul 17 '05 #7
KJM
I should have also listed that I'm using Windows XP.


"KJM" <k.***@cox.net> wrote in message
news:_t********************@news2.central.cox.net. ..
Hi,

My left monitor is #1 and my right monitor is #2 when I click Identify in
Windows Screen Properties, Setting

All of my monitors are added to the monitors collection in the sample code.
The problem is the function call

lReturn = MonitorFromWindow(hwnd, dwFlags)

Always returns a zero so the sample always centers a form on my left #1
screen.

I use the Matrox Millennium G550 video card, Driver version 5.86.32.0, Two monitors a 21" and a 19" both set to 1600 x 1200 resolution.

Thanks for your help
Ken
"B Pilgrim" <ex************@yahoo.se> wrote in message
news:%c*******************@newsb.telia.net...

"KJM" <k.***@cox.net> skrev i meddelandet
news:Q7*********************@news2.central.cox.net ...
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?

Use EnumDisplayMonitors to detect all monitors and get their resolution

with
GetMonitorInfo. There is a good example in the API-guide showing how to do this. It also shows how to use MonitorFromRect to determine on what

monitor
a form is located.

I don't know how your monitors are setup. Is the right one your primary
monitor? If you want to place a form at Left = 200 on your secondary

monitor
you must add the width of your primary monitor to the value. If the

primary
has a resolution of 800x600 the value would be 1000.
It would be more natural to have your primary monitor to the left and your secondary to the right since that's the way the "joined" desktop is
structured.


Jul 17 '05 #8
"KJM" <k.***@cox.net> skrev i meddelandet
news:_t********************@news2.central.cox.net. ..
The problem is the function call

lReturn = MonitorFromWindow(hwnd, dwFlags)

Always returns a zero so the sample always centers a form on my left #1
screen.


What code are you using when you try to position the form at your secondary
monitor? The form is loaded to the primary monitor by default so you have to
move it before you call MonitorFromWindow. Something like:

Me.Left = PrimaryMonitorWidth + (SecondaryMonitorWidth - Me.Width)/2

.... where the monitor widths are determined from the previous enumeration.
Just make sure that you use the same scalemode for all values.
Jul 17 '05 #9
> Use EnumDisplayMonitors to detect all monitors and get their resolution with
GetMonitorInfo. There is a good example in the API-guide showing how to do
this. It also shows how to use MonitorFromRect to determine on what monitor
a form is located.


A word of warning, though. Some graphic cards report two monitors as
one big monitor (with a resolution of, e.g. 2400x1024), notably all
ATI dual monitor cards I know and certain Matrox dual monitor cards.
To avoid having dialogs displayed between these two monitors
(centered) they usually come with extra applications like HydraVision,
or have driver extensions like PowerDesk that automatically position
windows.

If you have such a card, EnumDisplayMonitors does not help you in any
way. Otherwise it's very convenient, because it gives you the exact
size and position of every monitor, and you can decide where to move
the form based on that information.

Robert
Jul 17 '05 #10
sashi
1,754 Expert 1GB
hi there,

u want to detect or u want to be able to view the active monitor at a given instance..

well.. if you want to be able to detect currently installed monitor.. u can make use of WMI.. heard abt Windows Management Instrumentation?? very useful indeed.. check it out..
Jun 27 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Patrick | last post by:
I need some code for getting screenshots from the secondary monitor on dual monitor display. Here's a bit of the code for a screen from the primary monitor. Bitmap MyImage = new...
1
by: Patrick | last post by:
need some code for getting screenshots from the secondary monitor on dual monitor display. Here's a bit of the code for a screen from the primary monitor. Bitmap MyImage = new...
0
by: davsun55 | last post by:
I'm looking for a C# code example that show use of a dual monitor. My application will have a control console running on the main monitor (a la powerpoint slideshow), with a display window showing...
2
by: Mark | last post by:
Experts - I have a laptop running XP docked to a dual monitor setup. I find it quite annoying that even when I undock, I am still on dual monitor setting, which means some of my apps are on the...
9
by: Robert Porter | last post by:
I have been experimenting with the Screen object. It has a property called Screen.DeviceName which returns a string value similar to the following: \\.\DISPLAY1 or \\.\DISPLAY2 I have 2...
3
by: fournij | last post by:
Hi I'm writing a MFC C++ application using Visual .NET. I'm using a Dual Head video card with 2 monitors. I want to start my application in the first monitor but open a dialog box in the...
8
by: Sheldon | last post by:
I just received a 2nd (configured as a dual) monitor but, for Access only, I can't seem to figure out, if it's possible, to view, say, Table1 on one monitor and Table2 on the other monitor. If I...
0
by: praveenhathwar | last post by:
I ve developed an application. My client has two monitors for a single PC. He wants to display a video clip in the second monitor continuosly (Repeatedly) and when the application in runs in Primay...
1
by: nanban4u | last post by:
Hi, Programming Language - HTML, JavaScript Web server : IIS 6 Browser : IE 6 + I am working in a Dual Monitor screen setup. I have a scenario some times the user move the IE screen from...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.