Results 1 to 27 of 27

Thread: Extended Display

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    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?

  2. #2
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182
    Option Explicit should not be an Option!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: Extended Display

    Dosen't answer my question.

  4. #4
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    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!

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    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.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: Extended Display

    ? No ?

  7. #7
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    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!

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    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?

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    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

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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]).

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    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.

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    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

  15. #15
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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:
    1. Dim num As Long
    2.    num = Caption
    3.    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

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: Extended Display

    I get the error "subscript out of range" in the module higlighting:

    Code:
    Set Monitor = m_cM(index)

  17. #17
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  18. #18

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: Extended Display

    With that code I get the error "Invailed Qualifer"

  19. #19
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  20. #20

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: Extended Display

    Can you do me a favor and attach your code so I can compare them?

  21. #21
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  22. #22

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: Extended Display

    Well a way without class modules will save alot of trouble, did u get it to work properly?

  23. #23
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  24. #24

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: Extended Display

    Can you post the code so I can play around with it?

  25. #25

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: Extended Display

    This would be helpful...

  26. #26
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Extended Display

    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

  27. #27

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    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
  •  



Click Here to Expand Forum to Full Width