|
-
May 9th, 2009, 06:43 PM
#1
Thread Starter
Fanatic Member
Extended Display
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?
-
May 9th, 2009, 10:03 PM
#2
Frenzied Member
Option Explicit should not be an Option!
-
May 9th, 2009, 10:55 PM
#3
Thread Starter
Fanatic Member
Re: Extended Display
Dosen't answer my question.
-
May 10th, 2009, 10:44 PM
#4
Frenzied Member
Re: Extended Display
first link leads you to MS and a link for MultiMon.exe where...
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.
The second link tells you all about virtual monitors and how they could be layed out and how to detect it and how many monitors
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.
Option Explicit should not be an Option!
-
Aug 1st, 2009, 09:56 PM
#5
Thread Starter
Fanatic Member
Re: Extended Display
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.
-
Aug 3rd, 2009, 01:08 PM
#6
Thread Starter
Fanatic Member
-
Aug 3rd, 2009, 11:33 PM
#7
Frenzied Member
Re: Extended Display
Okay, considering that the computer than I am presently on does not have vb6 installed, I looked at frmTestMonitors.frm via notepad and found...
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))
'...
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.
Good Luck
Option Explicit should not be an Option!
-
Aug 4th, 2009, 01:02 AM
#8
Thread Starter
Fanatic Member
Re: Extended Display
Well I get the type mismatch error with this:
Code:
Set cMonTo = m_cM.Monitor(CLng(DefaultDisplay.Caption))
and this:
Code:
Set cMonTo = m_cM.Monitor(CInt(DefaultDisplay.Caption))
you can't have:
Code:
Set cMonTo = m_cM.Monitor CLng(DefaultDisplay.Caption)
or this:
Code:
Set cMonTo = m_cM.Monitor CInt(DefaultDisplay.Caption)
Because you get the same error. What am I doing wrong?
-
Aug 4th, 2009, 06:21 AM
#9
Re: Extended Display
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.
-
Aug 4th, 2009, 09:20 PM
#10
Thread Starter
Fanatic Member
Re: Extended Display
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
-
Aug 5th, 2009, 05:03 AM
#11
Re: Extended Display
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]).
-
Aug 12th, 2009, 03:12 AM
#12
Thread Starter
Fanatic Member
Re: Extended Display
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.
-
Aug 12th, 2009, 07:10 AM
#13
Re: Extended Display
Re-read the last line of my previous post.
If you have 2 monitors, the first will probably be index number 0.
-
Oct 18th, 2009, 06:03 PM
#14
Thread Starter
Fanatic Member
Re: Extended Display
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
-
Oct 19th, 2009, 06:17 AM
#15
Re: Extended Display
If you have 2 monitors, the first will probably be index number 0.
not in this case, the code passes 1 or 2, for 2 monitors
tested this, works fine
vb Code:
Dim num As Long num = Caption Set cMonTo = m_cM.Monitor(num) '(cboMonitors.ItemData(cboMonitors.ListIndex))
Last edited by westconn1; Oct 19th, 2009 at 06:31 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 19th, 2009, 07:27 PM
#16
Thread Starter
Fanatic Member
Re: Extended Display
I get the error "subscript out of range" in the module higlighting:
Code:
Set Monitor = m_cM(index)
-
Oct 19th, 2009, 08:59 PM
#17
Re: Extended Display
Set Monitor = m_cM(index)
try
Set Monitor = m_cM.Monitor(index)
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 20th, 2009, 08:19 PM
#18
Thread Starter
Fanatic Member
Re: Extended Display
With that code I get the error "Invailed Qualifer"
-
Oct 21st, 2009, 01:31 AM
#19
Re: Extended Display
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 21st, 2009, 06:43 PM
#20
Thread Starter
Fanatic Member
Re: Extended Display
Can you do me a favor and attach your code so I can compare them?
-
Oct 21st, 2009, 09:07 PM
#21
Re: Extended Display
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 21st, 2009, 11:02 PM
#22
Thread Starter
Fanatic Member
Re: Extended Display
Well a way without class modules will save alot of trouble, did u get it to work properly?
-
Oct 22nd, 2009, 02:15 AM
#23
Re: Extended Display
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 22nd, 2009, 11:15 AM
#24
Thread Starter
Fanatic Member
Re: Extended Display
Can you post the code so I can play around with it?
-
Oct 29th, 2009, 11:29 AM
#25
Thread Starter
Fanatic Member
-
Oct 29th, 2009, 03:56 PM
#26
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 2nd, 2009, 12:43 PM
#27
Thread Starter
Fanatic Member
Re: Extended Display
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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|