Returns the active Window object.
Visual Basic |
---|
Public Property ActiveWindow As Object |
Option Infer On Imports System Imports System.Runtime.InteropServices Namespace Examples Friend Class Program <STAThread> Shared Sub Main(ByVal args() As String) Dim application As SolidEdgeFramework.Application = Nothing Try ' See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic. OleMessageFilter.Register() ' Attempt to connect to a running instance of Solid Edge. application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application) ' ActiveWindow will throw an exception if no document is open. ' Get the active window. Dim activeWindow = application.ActiveWindow ' 3D windows will be of type SolidEdgeFramework.Window. Dim window = CType(activeWindow, SolidEdgeFramework.Window) ' 2D windows will be of type SolidEdgeDraft.SheetWindow. Dim sheetWindow = CType(activeWindow, SolidEdgeDraft.SheetWindow) Catch ex As System.Exception Console.WriteLine(ex) Finally OleMessageFilter.Unregister() End Try End Sub End Class End Namespace
using System; using System.Runtime.InteropServices; namespace Examples { class Program { [STAThread] static void Main(string[] args) { SolidEdgeFramework.Application application = null; try { // See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic. OleMessageFilter.Register(); // Attempt to connect to a running instance of Solid Edge. application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application"); // ActiveWindow will throw an exception if no document is open. // Get the active window. var activeWindow = application.ActiveWindow; // 3D windows will be of type SolidEdgeFramework.Window. var window = (SolidEdgeFramework.Window)activeWindow; // 2D windows will be of type SolidEdgeDraft.SheetWindow. var sheetWindow = (SolidEdgeDraft.SheetWindow)activeWindow; } catch (System.Exception ex) { Console.WriteLine(ex); } finally { OleMessageFilter.Unregister(); } } } }