How to Make SE application form to be the owner for a VB application

Does any one knows how to set Solid Edge Application Form to be the Owner for VB.net application form?

 

What I mean   is once you run the VB program in SOlid Edge I want the the VB form to get hiddend when SE is minimized and to show when SE is not minimized. And VB program to get ended if SE is closed by user . Is this too difficult to do?

 

Any direction would be greatly appreciated.

 

Sergio

 

 

Posted by: Sergio Vallejo
Post date: 8/15/2011 4:18:11 AM

8 REPLIES

RE: How to Make SE application form to be the owner for a VB application

You can try to use the Windows API with SetParent for your Form.

 

JR

 

Posted by: JR
Post date: 8/19/2011 1:51:09 AM

RE: How to Make SE application form to be the owner for a VB application

Hi Sergio,

 

you can accomplish this by connecting to events provided by the ApplicationEvents and ApplicationWindowEvents objects of the Solid Edge Application object.

Just declare 2 variables as shown below and then provide event handlers for the events you are interested in (the Visual Studio IDE is very helpful in creating the stub for an event handler routine):

 

Dim WithEvents appEvents as ApplicationEvents = seApp.ApplicationEvents

Dim WithEvents appWindowEvents as ApplicationWindowEvents = seApp.ApplicationWindowEvents

 

 

Posted by: Wolfgang Kunert
Post date: 8/19/2011 2:40:26 AM

RE: How to Make SE application form to be the owner for a VB application

Kunert,

 

I get this error when I declare the types:

 

Error 1 Interop type 'ApplicationEvents' cannot be embedded because it is missing the required 'Guid' attribute. CasingManager

 

any idea to solve this and also any directions how to use these types?

 

Thanks

Sergio

 

 

Posted by: Sergio Vallejo
Post date: 8/19/2011 4:58:15 AM

RE: How to Make SE application form to be the owner for a VB application

Sergio,

 

looking into the Solid Edge help shows following required declarations:

 

Dim WithEvents appEvents as SolidEdgeFramework.ISEApplicationEvents_Event

Dim WithEvents appWindowEvents as SolidEdgeFramework.ISEApplicationWindowEvents_Event

 

You find examples in the document "mu28000.pdf" which is delivered since Solid Edge ST starting from page 123 ff

 

 

Posted by: Wolfgang Kunert
Post date: 8/21/2011 10:05:55 PM

RE: How to Make SE application form to be the owner for a VB application

Hi Kunert,

 

I followed your recommendationsfor using the handeling events. Ii can see the application events and I think you pointed me in the right direction. I can see the appication events and write some code in them; how ever I get an error when i set the objAppEvents then none of the handeling events that im trying to use get triggered. Any help?

 

Imports System.Runtime.InteropServices

Imports SolidEdgeFramework

 

Public Class Form1

 

Private objApplication As SolidEdgeFramework.Application

Private WithEvents objAppEvents As SolidEdgeFramework.ISEApplicationEvents_Event

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try

' Connect to a running instance of Solid Edge

objApplication = Marshal.GetActiveObject("SolidEdge.Application")

' Get a reference to the application events

objAppEvents = objApplication.ApplicationEvents

Catch ex As Exception

Console.WriteLine(ex.Message)

End Try

End Sub

 

I get an error when the program executes this line:

 

objAppEvents = objApplication.ApplicationEvents

 

this is the exception is trowing: event invocation for COM objects requires event to be attributed with DispIdAttribute.

 

Any help.

 

Thanks

Sergio

 

 

Posted by: Sergio Vallejo
Post date: 8/31/2011 3:38:50 AM

RE: How to Make SE application form to be the owner for a VB application

Hi Sergio,

 

try using the type DISEApplicationEvents_Event instead of ISEApplicationEvents_Event.

Seems to work only that way.

 

Posted by: Wolfgang Kunert
Post date: 8/31/2011 11:14:37 PM

RE: How to Make SE application form to be the owner for a VB application

Thanks Kunert.

 

it did work just like I needed. Do you know any handeling event that triggers when Solid Edge is minimazed?

 

Thanks Again your tips have been very helpful.

 

Sergio

 

 

Posted by: Sergio Vallejo
Post date: 9/1/2011 4:39:15 AM

RE: How to Make SE application form to be the owner for a VB application

To answer your original question, the correct way to implement what you're asking for is as shown below.  You first need to create a new class named ApplicationWindow.

Imports SystemImports System.Runtime.InteropServicesImports System.Windows.FormsNamespace Example _ Public Class ApplicationWindow Implements System.Windows.Forms.IWin32Window Private phandle As IntPtr Public Sub New(ByVal handle As Integer) Me.phandle = New IntPtr(handle) End Sub Public Sub New(ByVal handle As IntPtr) Me.phandle = handle End Sub Public ReadOnly Property Handle() As System.IntPtr Implements System.Windows.Forms.IWin32Window.Handle Get Handle = Me.phandle End Get End Property End ClassEnd Namespace

You then use the class like this.

Dim frm As New MyForm'application refers to the main SolidEdgeFramework.Application object.frm.ShowDialog(New Example.ApplicationWindow(application.hWnd))

 

Posted by: Jason Newell
Post date: 9/4/2011 10:40:27 PM