2 Replies Latest reply on Jun 27, 2018 9:33 AM by Cai Industries

    It possible open the solid works frame in a windows .NET form a tabpage ?

    Cai Industries

      I want open solidworks frame like this man open cal.exe in this video. :

      https://www.youtube.com/watch?v=N6GWgxEvibE

      is  it possible ?

      is it possible open sldworks in a tab page of a tab control ?

      is it possible open sldworks in a panel of split container ?

       

      I can command via Api frameposition , frame height .. but non set it as Child .

      Best reards

        • Re: It possible open the solid works frame in a windows .NET form a tabpage ?
          Artem Taturevych

          Yes. You need to get the hwnd of sw via 2015 SOLIDWORKS API Help - GetHWnd Method (IFrame) and use win api to change the parent (similar to the video you have shown)

          • Re: It possible open the solid works frame in a windows .NET form a tabpage ?
            Cai Industries

            YES IT  WORKS ! .

             

            First all it Need to create a singleton class :

             

            Imports SolidWorks.Interop.sldworks

             

            Namespace SWXSTANDALONE

                Friend Class SolidWorksSingleton

                    Private Shared swApp As SldWorks

             

                    Private Sub New()

                    End Sub

             

                    Friend Shared Function getApplication() As SldWorks

                        If swApp Is Nothing Then

                            swApp = TryCast(Activator.CreateInstance(Type.GetTypeFromProgID("SldWorks.Application")), SldWorks)

                            swApp.Visible = True

                            Return swApp

                        End If

             

                        Return swApp

                    End Function

             

                End Class

             

            End Namespace

             

            Then for open sldworks frame in  a Windows form  :

             

            Imports SolidWorks.Interop.sldworks

             

            Public Class Form1

                Public Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As_ System.IntPtr

             

                Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

                    Dim swapp As SldWorks = SWXSTANDALONE.SolidWorksSingleton.getApplication()

                    Dim swframe As IFrame

                    swframe = swapp.Frame

                    SetParent(swframe.GetHWnd(), Me.Handle)

                End Sub

            End Class

            1.PNG

            Or  for open sldworks frame in  a split container panel   :

             

            Imports SolidWorks.Interop.sldworks

            Public Class Form1

             

                Public Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal_ hWndNewParent As IntPtr) As System.IntPtr

                Declare Auto Function SendMessage Lib "user32" (ByVal hWnd As IntPtr, ByVal Msg As Integer,_ ByVal wParam As Integer, ByVal lParam As Integer) As Integer

                Private Const WM_SYSCOMMAND As Integer = 274

                Private Const SC_MAXIMAZE As Integer = 61488

                Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

             

                    Dim swapp As SldWorks = SWXSTANDALONE.SolidWorksSingleton.getApplication()

                    Dim swframe As IFrame

                    swframe = swapp.Frame

             

                    SetParent(swframe.GetHWnd(), SplitContainer1.Panel2.Handle)

                    SendMessage(swframe.GetHWnd(), WM_SYSCOMMAND, SC_MAXIMAZE, 0)

                    Me.BringToFront()

                End Sub

             

            End Class

             

            2.PNG

            The code reported works if SLDWORKS process non it running!.