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 - 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...
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...
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
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
#
#
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...
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 - MVP VB
http://KillerVB.com
+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message
news:eQPk6$m5CHA...@TK2MSFTNGP11.phx.gbl...
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 - MVP VB
+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+
"Randy Birch" <r...@mvps.org> wrote in message
news:OGB3c715...@TK2MSFTNGP09.phx.gbl...