8 Replies Latest reply on Apr 17, 2018 10:15 AM by Kevin Andrews

    Anyone else spread their work across two monitors?

    Kevin Andrews

      I don't usually spread my desktop across both of my monitors, but I am currently working on a project where I have to. I am doping this because I need to have two different files open for reference. So, I set one file to one monitor and the other file to the other monitor.

       

      Is there a way that I can maximize the screen on each monitor for the file that is on that monitor? Right now, they both just float around a little bit. For someone with learned OCD, this is very unnerving.

        • Re: Anyone else spread their work across two monitors?
          Josh Brady

          What version of SW are you using?  Do you not have all the buttons shown here?

           

            • Re: Anyone else spread their work across two monitors?
              Kevin Andrews

              2017 - and yes, I have those buttons but they only serve to say which monitor it will be on. It doesn't do anything for maximizing the screen per monitor.

                • Re: Anyone else spread their work across two monitors?
                  Josh Brady

                  You can try playing with this macro.  You'll have to map it to a shortcut key or to a mouse button because it operates on the SW document under the cursor.  If you map it to a button or try to run it from the VBA editor it won't work.

                   

                  I wrote this years ago before there was any dual monitor support in SW.  It moves the window under the cursor without actually activating that document.  This allows you to page back and forth across documents, flinging them from one monitor to the other without activating and waiting for them to rebuild.

                   

                  You need two versions, one to fling left and the other to fling right.  The only difference between the two is the numbers on the line

                  boolstatus = SetWindowPos(ApiHandle, 0, 1845, -7, 1870, 1000, 16)

                   

                  For me, I use the above numbers for the right monitor, and for left: (ApiHandle, 0, -7, -8, 1855, 1000, 16)

                   

                  The third and fourth arguments of SetWindowPos are the position, in pixels, of the top left corner of the window, relative to the SW window.  You can see I have some negative numbers in there to force the borders of the window off the viewable area and maximize space for the graphics.  The fifth and sixth are the window size in pixels. 

                   

                  Dim swApp As SldWorks.SldWorks
                  Dim Part As SldWorks.ModelDoc2
                  Dim boolstatus As Boolean
                  Dim longstatus As Long, longwarnings As Long
                  Dim FeatureData As Object
                  Dim Feature As Object
                  Dim Component As Object
                  Dim MainHandle As LongPtr
                  Dim ActiveHandle As LongPtr
                  Dim ApiHandle As LongPtr
                  Dim ClassName As String
                  
                  
                  
                  
                  Const TOPWINDOWCLASS As String = "MDIClient"
                  
                  
                  
                  
                  Dim myPt As POINTAPI
                  
                  
                  Private Type POINTAPI
                          X As Long
                          Y As Long
                  End Type
                  
                  
                  Private Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As _
                     POINTAPI) As Long
                     
                  Private Declare PtrSafe Function WindowFromPoint Lib "user32" _
                      (ByVal Point As LongLong) As LongPtr
                  
                  
                  Private Declare PtrSafe Function GetClassName Lib "user32" Alias _
                     "GetClassNameA" (ByVal hWnd As LongPtr, ByVal lpClass _
                      As String, ByVal nMaxCount As Long) As Long
                      
                  Private Declare PtrSafe Function SetWindowPos Lib "user32" _
                      (ByVal hWnd As LongPtr, _
                      ByVal hWndInsertAfter As LongPtr, _
                      ByVal X As Long, _
                      ByVal Y As Long, _
                      ByVal cx As Long, _
                      ByVal cy As Long, _
                      ByVal uFlags As Long) As Boolean
                  
                  
                  Private Declare PtrSafe Function GetParent Lib "user32" _
                      (ByVal hWnd As LongPtr) As LongPtr
                      
                  Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As LongPtr)
                      
                      
                      
                  
                  
                  Sub main()
                  
                  
                  Set swApp = Application.SldWorks
                  Set Part = swApp.ActiveDoc
                  
                  
                  longstatus = GetCursorPos(myPt)
                  
                  
                  ApiHandle = WindowFromPoint(PointToLongLong(myPt))
                  ClassName = String$(256, " ")
                  longstatus = GetClassName(GetParent(ApiHandle), ClassName, 255)
                  ClassName = VBA.Left$(ClassName, VBA.InStr(ClassName, vbNullChar) - 1)
                  'Debug.Print ClassName
                  Do While StrComp(ClassName, TOPWINDOWCLASS, vbTextCompare) <> 0
                      ''''getting class name
                      ApiHandle = GetParent(ApiHandle)
                      ClassName = String$(256, " ")
                      longstatus = GetClassName(GetParent(ApiHandle), ClassName, 255)
                      If Len(Trim(ClassName)) = 0 Then
                          Exit Sub
                      End If
                      ClassName = Left$(ClassName, InStr(ClassName, _
                           vbNullChar) - 1)
                      '''''end getting class name
                      'Debug.Print ClassName
                  Loop
                      
                  boolstatus = SetWindowPos(ApiHandle, 0, 1845, -7, 1870, 1000, 16) 'for 2 monitors
                  'boolstatus = SetWindowPos(ApiHandle, 0, (1625 / 2) - 20, -7, 1610 / 2, 985, 16)
                  'If swApp.ActiveDoc Is Nothing Then Exit Sub
                  'swApp.ActiveDoc.ActiveView.FrameState = 0
                  'swApp.ActiveDoc.ActiveView.FrameWidth = 996
                  'swApp.ActiveDoc.ActiveView.FrameHeight = 700
                  'swApp.ActiveDoc.ActiveView.FrameLeft = 963
                  'swApp.ActiveDoc.ActiveView.FrameTop = -7
                  
                  
                  End Sub
                  
                  
                  Function PointToLongLong(Point As POINTAPI) As LongLong
                      Dim ll As LongLong
                      Dim cbLongLong As LongPtr
                      
                      cbLongLong = LenB(ll)
                      
                      ' make sure the contents will fit
                      If LenB(Point) = cbLongLong Then
                          CopyMemory ll, Point, cbLongLong
                      End If
                      
                      PointToLongLong = ll
                  End Function
                  
              • Re: Anyone else spread their work across two monitors?
                Dan Pihlaja

                Agreed.  And no....there is no way.  You cannot maximize it for each monitor (unless they fixed it for SW 2018.   It will fill most of the space in the main Solidworks window, but it will NOT be maximized.   Honestly, this bugs me so much that I never use it.

                 

                I wish that it worked like Microsoft Word does (in this specific instance), in which, when you open a new document, it creates a separate window that you can then maximize in each monitor if you want.  Right now, as it stands, spanning desktops is unusable at worst, and really annoying at best.

                 

                Read through this: What does support for Dual Monitors mean to you?

                • Re: Anyone else spread their work across two monitors?
                  Jody Smith

                  There used to be a great program called ultramon that gave you all kinds of nifty controls over multiple displays. I know this is kind of the opposite of multiple monitors, but perhaps they might have something that will give you control over this?