Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dual Monitors

45 views
Skip to first unread message

Tim

unread,
Mar 9, 2003, 1:34:51 PM3/9/03
to
I am about to write a very simple program for my church who has recently had
setup a projection system. The PC runs WinXP Pro, and has a dual-head video
card. Obviously, one for the system, and the other one is the extension of the
windows desktop which is what is projected on the screens.

How can I, in VB 6, write a program that will center my form on the second
monitor? I am not sure of how that works... does the system see two monitors, or
just a very very wide on? :)

Thanks,
Tim


Ken Halter

unread,
Mar 9, 2003, 2:13:50 PM3/9/03
to
> just a very very wide on? :)
That depends on the graphics card settings. We have a couple dual head Matrox cards and they
can be setup to either show a double wide screen (drives me nuts because 1/2 of a msgbox (or
other dialog) will show on one monitor and the other 1/2 on the other... the Ok button is
split down the middle) or as 2 normal screens with the same stuff on each screen. I believe
I had mine set to "Wide" for about 2 hours... after that, I disconnected the extra monitor
and returned it to our stock. You'll probably be using the 2 separate (but normal) monitors.
No extra coding is required to center dialogs in this case. On the wide screen, you'd just
center it in one half of the screen or the other by using 1/2 the screen width instead of
the whole thing.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com/ - Please keep it in the groups

"Tim" <tim...@hotmail.com> wrote in message news:#3$8Som5C...@TK2MSFTNGP11.phx.gbl...

Tim

unread,
Mar 9, 2003, 2:57:31 PM3/9/03
to
From what you described, I believe it's setup with just two monitors. The
dialog boxes (even from the windows system itself) appear centered on the first
monitor. When you maximize a window, it conforms to that monitor also.

The resolution is 1280x1024 for both monitors. In VB, would it see the
Screen.Width as 1280 pixels or 2560 pixels?

"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message
news:eQPk6$m5CHA...@TK2MSFTNGP11.phx.gbl...

Mike D Sutton

unread,
Mar 9, 2003, 4:43:36 PM3/9/03
to

It depends how the machine is set up, but by default they're regarded as two
separate displays which exist in 'virtual space' in relation to one another,
this is usually the same relation as the physical devices have to one
another so if you drag a window off one monitor it appears to be dragged
over to the one next to it:
http://msdn.microsoft.com/library/en-us/gdi/monitor_7hym.asp

You can adjust the positions of the monitors in virtual space by using the
"Display Properties" dialog from Control panel, the last tab will appear
differently from that on a single device system.
To retrieve the positions of the monitors though code, you must enumerate
the available devices and get the API to return you their individual area's.
To get the number of monitors installed on the system, use the
GetSystemMetrics() API call with the SM_MONITORS flag:

'***
Public Declare Function GetSystemMetrics Lib _
"user32" (ByVal nIndex As Long) As Long

Public Const SM_CMONITORS As Long = 80

' ....

Call MsgBox(GetSystemMetrics(SM_CMONITORS) & _
" monitors detected", vbInformation)
'***

If multiple monitors are detected then you can go ahead and enumerate them:

'***
' * Place the following in a _module_, not in a form or class *

Public Declare Function EnumDisplayMonitors Lib "user32" _
(ByVal hdc As Long, ByVal lprcClip As Long, _
ByVal lpfnEnum As Long, ByVal dwData As Long) As Long

Public Declare Function GetMonitorInfo Lib "user32" Alias _
"GetMonitorInfoA" (ByVal hMonitor As Long, _
ByRef lpmi As MONITORINFOEX) As Long

Private Const CCHDEVICENAME As Long = 32

Public Type MonitorRect ' RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Public Type MONITORINFOEX
cbSize As Long
rcMonitor As MonitorRect
rcWork As MonitorRect
dwFlags As Long
szDevice As String * CCHDEVICENAME
End Type '*LPMONITORINFOEX;

Public Type typEnumMonitorInf
emiHMonitor As Long
emiHDC As Long
emiRect As MonitorRect
emiData As Long
emiMIEx As MONITORINFOEX
End Type

Private MonitorList() As typEnumMonitorInf
Private NumEnumMonitors As Long

Public Function GetMonitors(ByRef outList() As typEnumMonitorInf) As Long
NumEnumMonitors = 0 ' Clear any existing data
Erase MonitorList

If (EnumDisplayMonitors(ByVal 0&, ByVal 0&, _
AddressOf MonitorEnumProc, 0)) Then outList = MonitorList

GetMonitors = NumEnumMonitors
End Function

Private Function MonitorEnumProc(ByVal hMonitor As Long, _
ByVal hdcMonitor As Long, ByRef lprcMonitor As MonitorRect, _
ByVal dwData As Long) As Long
ReDim Preserve MonitorList(NumEnumMonitors) As typEnumMonitorInf

With MonitorList(NumEnumMonitors)
.emiHMonitor = hMonitor
.emiHDC = hdcMonitor
.emiRect = lprcMonitor
.emiData = dwData
.emiMIEx.cbSize = Len(.emiMIEx)
Call GetMonitorInfo(hMonitor, .emiMIEx)
End With

NumEnumMonitors = NumEnumMonitors + 1

' Return 1 to continue enumeration
MonitorEnumProc = 1
End Function
'***

Now call GetMonitors() and it will return you the number of monitors and
information for each one. You can then use the .rcMonitor property of the
returned MONITORINFOEX structure for each monitor to get their virtual
space, and position your window accordingly within this area.
Hope this helps,

Mike


-- EDais --

- Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/
Work E-Mail: ED...@btclick.com
Other E-Mail: Mike....@btclick.com


Randy Birch

unread,
Mar 9, 2003, 6:29:38 PM3/9/03
to
See the entires on this page ...
http://www.mvps.org/vbnet/code/screen/index.html

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.


"Tim" <tim...@hotmail.com> wrote in message
news:#3$8Som5C...@TK2MSFTNGP11.phx.gbl...

# I am about to write a very simple program for my church who has recently
had
# setup a projection system. The PC runs WinXP Pro, and has a dual-head
video
# card. Obviously, one for the system, and the other one is the extension
of the
# windows desktop which is what is projected on the screens.
#
# How can I, in VB 6, write a program that will center my form on the second
# monitor? I am not sure of how that works... does the system see two
monitors, or
# just a very very wide on? :)
#
# Thanks,
# Tim
#
#


Tim

unread,
Mar 9, 2003, 11:12:17 PM3/9/03
to
I think this would really help me, but I'm having trouble understanding the
syntax of GetMonitors()

I need to call it with an argument. I tried declaring my own array, and it
gives me a type mismatch error.

What's the procedure for calling that function?

Thanks

"Mike D Sutton" <Mike....@btclick.com> wrote in message
news:eF4FwSo5...@TK2MSFTNGP12.phx.gbl...

Tim

unread,
Mar 10, 2003, 1:06:23 AM3/10/03
to
I think I figured it out.....

I wasn't specifying the array "()" after the end of my own array name.... so in
that case, it is working now :)

Tim

THANKS


"Tim" <tim...@hotmail.com> wrote in message

news:OWfm8qr...@TK2MSFTNGP11.phx.gbl...

Monte Hansen

unread,
Mar 10, 2003, 1:44:47 AM3/10/03
to
Yeah, I run with dual monitors via an ATI card, under which no special
programming is required. That is, it's delegated to the "Hydravision" app
that ships with the card. Although, it drives me nuts when you right click
on a form, and the popup menu displays on the other monitor (sometimes).

+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+
Monte Hansen - MVP VB
http://KillerVB.com
+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+

"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message
news:eQPk6$m5CHA...@TK2MSFTNGP11.phx.gbl...

Randy Birch

unread,
Mar 10, 2003, 6:43:16 PM3/10/03
to
I solved that by running my Dell 420 with dual video cards. I initially had
the dual-head matrox, but hated the taskbar across both monitors. Now one is
my news & vb monitor (with the taskbar) and the other is my msdn/vc/ie
screen. And no more msgboxes in the middle of the screen either.

Now if I could get a new box that supported dual xenon and dual AGP slots,
that would be perfect. Right now the ATI card is running PCI, and is
noticeably slower than the nvidia card.

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.


"Monte Hansen" <mo...@nospam.com> wrote in message
news:u230cCt5...@TK2MSFTNGP09.phx.gbl...
# Yeah, I run with dual monitors via an ATI card, under which no special
# programming is required. That is, it's delegated to the "Hydravision" app
# that ships with the card. Although, it drives me nuts when you right click
# on a form, and the popup menu displays on the other monitor (sometimes).
#
# +|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+
# Monte Hansen - MVP VB
# http://KillerVB.com
# +|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+
#
# "Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message
# news:eQPk6$m5CHA...@TK2MSFTNGP11.phx.gbl...
# > > just a very very wide on? :)
# > That depends on the graphics card settings. We have a couple dual head
Matrox cards
# and they
# > can be setup to either show a double wide screen (drives me nuts because
1/2 of a
# msgbox (or
# > other dialog) will show on one monitor and the other 1/2 on the other...
the Ok button
# is
# > split down the middle) or as 2 normal screens with the same stuff on
each screen. I
# believe
# > I had mine set to "Wide" for about 2 hours... after that, I disconnected
the extra
# monitor
# > and returned it to our stock. You'll probably be using the 2 separate
(but normal)
# monitors.
# > No extra coding is required to center dialogs in this case. On the wide
screen, you'd
# just
# > center it in one half of the screen or the other by using 1/2 the screen
width instead
# of
# > the whole thing.
# >
# > --
# > Ken Halter - MS-MVP-VB - http://www.vbsight.com/ - Please keep it in the
groups
# >
# > "Tim" <tim...@hotmail.com> wrote in message
# news:#3$8Som5C...@TK2MSFTNGP11.phx.gbl...
# > > I am about to write a very simple program for my church who has
recently had
# > > setup a projection system. The PC runs WinXP Pro, and has a dual-head
video
# > > card. Obviously, one for the system, and the other one is the
extension of the
# > > windows desktop which is what is projected on the screens.
# > >
# > > How can I, in VB 6, write a program that will center my form on the
second
# > > monitor? I am not sure of how that works... does the system see two
monitors, or


# > > just a very very wide on? :)
# > >
# > > Thanks,
# > > Tim
# > >
# > >

# >
# >
#


Monte Hansen

unread,
Mar 14, 2003, 12:29:41 AM3/14/03
to
Actually, the hydravision app bundled with ATI Radeon's works pretty good. None of that
"in the middle of the screen"stuff. I don't know about the speed thing, since I don't do
much gaming (my wife would kill me if I got "hooked on to something else" ;-)

+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+

Monte Hansen - MVP VB

http://KillerVB.com


+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+

"Randy Birch" <r...@mvps.org> wrote in message
news:OGB3c715...@TK2MSFTNGP09.phx.gbl...

0 new messages