I have a question is there a way to detect displays and check to see if there is an extened display and then if there is it can show a form in the extened display centered?
Printable View
I have a question is there a way to detect displays and check to see if there is an extened display and then if there is it can show a form in the extened display centered?
Dosen't answer my question.
first link leads you to MS and a link for MultiMon.exe where...
The second link tells you all about virtual monitors and how they could be layed out and how to detect it and how many monitorsQuote:
Multimon.exe is a sample project that shows how to detect and handle multiple monitors on Windows 98 and Windows Me.
The sample project includes a reusable class that makes adding multiple monitor support to applications easier.
Fourth link will keep you busy for a month with more information than you asked for.
So as for not answering your question, perhaps you should look again.
I went with option number 3 and downloaded the example:
http://rds.yahoo.com/_ylt=A0oGkmND_3...rs/article.asp
Is there a way where instead of using a combobox i can use a label with the selected monitor I want in it? Because i divised a way that would load the settings from a file.
? No ?
Okay, considering that the computer than I am presently on does not have vb6 installed, I looked at frmTestMonitors.frm via notepad and found...
So, it seems to me, that if you have the correct information stored within the text file, you should not need a label but if you really want a label instead of the combo box or nothing, then just put the required information into the caption of the label but dont forget to use clng(lable1.caption) (that is if function expects long) or cint, etc.Code:Private Sub cmdCentre_Click()
Dim cMonTo As cMonitor
Dim lWidth As Long
Dim lHeight As Long
Set cMonTo = m_cM.Monitor(cboMonitors.ItemData(cboMonitors.ListIndex))
'...
Good Luck
Well I get the type mismatch error with this:
and this:Code:Set cMonTo = m_cM.Monitor(CLng(DefaultDisplay.Caption))
you can't have:Code:Set cMonTo = m_cM.Monitor(CInt(DefaultDisplay.Caption))
or this:Code:Set cMonTo = m_cM.Monitor CLng(DefaultDisplay.Caption)
Because you get the same error. What am I doing wrong?Code:Set cMonTo = m_cM.Monitor CInt(DefaultDisplay.Caption)
What is the value of DefaultDisplay.Caption ?
If it contains anything other than a number then it can't be converted to a number - so a Data Type Mismatch error is to be expected.
Ok, Now changing that to a number I get the following error:
Error 9: Subscript Out Of Range In The Following Class: (cMonitors)
Code:Public Property Get Monitor(ByVal index As Long) As cMonitor
Set Monitor = m_cM(index)
End Property
I recommend you read (and preferably bookmark/print/save) the article What does this error mean, and how do I fix it? from our Classic VB FAQs (in the FAQ forum)
In this case the problem is that the number you provided is not valid.
I haven't downloaded the code, but I suspect cMonitors has a property which tells you what the maximum allowed value is (or the number of monitors, which will presumably be one higher [as arrays normally start at 0]).
I read the article, but I'm confused because my computer currently has 2 displays and in a caption I have a "2" indicating I want to use the 2nd display but I get this error.
Re-read the last line of my previous post.
If you have 2 monitors, the first will probably be index number 0.
Well I posted the code that I have. I can't seem to get it to work. So what happens is that the program checks to see if a file exists so it can change the display if it exists then it loads the display from the database. Is there a way where I can read it from a database and but it in a capttion what display I want to use then it can switch. Because the code uses a combobox and I don't want to use a combobox.
Code:'******************************************************************
'Check To See If Extended Display Will Be Used
'******************************************************************
Dim IntCheckFile As Integer
IntCheckFile = FileExists(App.Path & "\Data\ExtendedDisplay.ini")
Select Case IntCheckFile
Case -1
'(NOT USED)
Case 0
'(NOT USED)
Case 1
'******************************************************************
'Show The Extended Display Message
'******************************************************************
msg = "Super Trivia! detected that you have saved your extended display settings and will now try to attempt to reload those settings."
MsgBox msg, vbOKOnly, "Super Trivia! - Extended Display Detected"
'******************************************************************
'Load The Monitor Settings
'******************************************************************
dbPath = App.Path & "\Data\Settings.mdb"
Set Mydb = DBEngine.Workspaces(0).OpenDatabase(dbPath, True, False, ";pwd=" & ENGINE.EnginePassword.Caption & "")
Set Myrs = Mydb.OpenRecordset("WindowMode", dbOpenSnapshot)
Myrs.MoveFirst
A$ = Myrs!CustomDisplay
ENGINE.TEMPDATA.Caption = A$
DefaultDisplay.Caption = TEMPDATA.Caption
Myrs.Close
Set Myrs = Nothing
'******************************************************************
'Make Setting Loaded Default Display
'******************************************************************
Dim bFound As Boolean
For i = 0 To cboMonitors.ListCount - 1
If cboMonitors.List(i) = TEMPDATA.Caption Then
bFound = True
Exit For
End If
Next i
If bFound Then
cboMonitors.RemoveItem i
End If
cboMonitors.AddItem TEMPDATA.Caption, 0
cboMonitors.TEXT = TEMPDATA.Caption
cboMonitors.RemoveItem ("\\.\DISPLAY1")
cboMonitors.ListIndex = 0
'******************************************************************
'Move The Engine To The Correct Monitor
'******************************************************************
Dim cMonTo As cMonitor
Dim cMonFrom As cMonitor
'Set cMonTo = m_cM.Monitor(cboMonitors.ItemData(cboMonitors.ListIndex))
Set cMonTo = m_cM.Monitor(CInt(DefaultDisplay.Caption))
Set cMonFrom = m_cM.MonitorForWindow(Me.hwnd)
If Not (cMonTo.hMonitor = cMonFrom.hMonitor) Then
Dim lOffsetX As Long
Dim lOffsetY As Long
lOffsetX = ScaleX(Me.Left, vbTwips, vbPixels) - cMonFrom.Left
lOffsetY = ScaleY(Me.Top, vbTwips, vbPixels) - cMonFrom.Top
If (lOffsetX < 0) Then
lOffsetX = 32
End If
If (lOffsetY < 0) Then
lOffsetY = 32
End If
Me.Move Me.ScaleX(cMonTo.Left, vbPixels, vbTwips), Me.ScaleY(cMonTo.Top, vbPixels, vbTwips)
End If
End Select
not in this case, the code passes 1 or 2, for 2 monitorsQuote:
If you have 2 monitors, the first will probably be index number 0.
tested this, works fine
vb Code:
Dim num As Long num = Caption Set cMonTo = m_cM.Monitor(num) '(cboMonitors.ItemData(cboMonitors.ListIndex))
I get the error "subscript out of range" in the module higlighting:
Code:Set Monitor = m_cM(index)
tryQuote:
Set Monitor = m_cM(index)
Set Monitor = m_cM.Monitor(index)
With that code I get the error "Invailed Qualifer"
i have no idea then, i have tested the code, any invalid value will return subscript out of range error, you must have broke some of code, somewhere
Can you do me a favor and attach your code so I can compare them?
i just download the sample from the link you showed above, then modified it slightly to pass values directly, all worked without problem
i also tried the microsoft mutimon example, but note it has an error in one of the api declares, it works fine when fixed, but probably not much difference between the 2
i have been playing with another method, which uses no classes (class modules), just stores monitor values in an array, with proceedures to move a form to same position on another monitor or center the form on its current monitor, but i can only test on 2 monitors, and am not sure what result would be got for monitors attached to different video cards
Well a way without class modules will save alot of trouble, did u get it to work properly?
it is working correctly on my machine, running XP and single vid card, can not say beyond that at this stage, i only have this computer with multiple monitors, so further testing is difficult
Can you post the code so I can play around with it?
This would be helpful...
i have uploaded a project here
http://www.vbforums.com/showthread.p...00#post3644600
I seen your project that you posted and it works great, but I have a question can you also post the first project you were working on that you said that you didn't have any errors on? Post #23 Because I want to get that code working because it just urks me to not know why its working...