Option Infer On
Imports System
Imports System.Runtime.InteropServices
Imports System.Runtime.InteropServices.ComTypes
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Implements SolidEdgeFramework.ISESPEvents
Private _application As SolidEdgeFramework.Application
Private _connectionPoint As IConnectionPoint
Private _cookie As Integer
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
' Connect to Solid Edge.
_application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
ConnectEvents()
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
DisconnectEvents()
End Sub
Private Sub ConnectEvents()
' Get the event GUID.
Dim typeGuid = GetType(SolidEdgeFramework.ISESPEvents).GUID
' Get a reference to the IConnectionPointContainer.
Dim container As IConnectionPointContainer = DirectCast(_application, IConnectionPointContainer)
' Lookup the IConnectionPoint.
container.FindConnectionPoint(typeGuid, _connectionPoint)
' Advise the sink.
_connectionPoint.Advise(Me, _cookie)
End Sub
Private Sub DisconnectEvents()
' Unadvise the sink.
_connectionPoint.Unadvise(_cookie)
' Clear variables.
_cookie = 0
_connectionPoint = Nothing
End Sub
#Region "ISESPEvents"
Public Sub SESP_BeforeCPDDisplay(pCPDInitializer As Object, eCPDMode As SolidEdgeFramework.eCPDMode) Implements SolidEdgeFramework.ISESPEvents.SESP_BeforeCPDDisplay
End Sub
Public Sub SESP_IsPreCPDEventSupported(ByRef pvbPreCPDEventSupported As Boolean) Implements SolidEdgeFramework.ISESPEvents.SESP_IsPreCPDEventSupported
pvbPreCPDEventSupported = True
End Sub
Public Sub SESPPDM_OnFileOpenUI(ByRef bstrFilename As String) Implements SolidEdgeFramework.ISESPEvents.SESPPDM_OnFileOpenUI
End Sub
#End Region
End Class