Solved! Go to solution

SE AddIn Message Box C#



I like to make an SE AddIn witch copy the material info before save. This is already working.


Now I would like that a Message Box opens, when there was a fault.


Please can you help me how I can display a message or a message box


Thank you for the help

Accepted by topic author bauer
‎08-26-2015 04:32 AM

Re: SE AddIn Message Box C#

In order to correctly show a MessageBox from an addin, you need to specify the "owner" of the dialog. To do that, you need a reference to a NativeWindow as shown below.


    throw new System.Exception("Test");
catch (System.Exception ex)
    IntPtr phWnd = new IntPtr(application.hWnd);
    System.Windows.Forms.NativeWindow owner = System.Windows.Forms.NativeWindow.FromHandle(phWnd);
    System.Windows.Forms.MessageBox.Show(owner, ex.Message, "Exception");

For further reading, you might take a look at my ShowDialog for Form and ShowDialog for CommonDialog extension methods of the SolidEdgeFramework.Application type on GitHub. That is the code behind my SolidEdge.Community NuGet package. You didn't specify how you've created your addin but my Solid Edge Community Templates Quick Start video is worth mentioning. It covers the Solid Edge Community Templates for Visual Studio and how to easily create an addin using the templates.

Jason Newell
Applications Architect

Re: SE AddIn Message Box C#

Thank you for your help, It works perfekt.