Reply

SEAddIn AfterWindowActivate

[ Edited ]

Hello,

 

I am working on an AddIn that was originally created in VB and would work fine.

Now however It has been switched to C# and the only problem I am left with is a constant error that appears whenever solidedge is closed. "Solid Edge has encountered a problem and needs to close. We are sorry for the inconvenience." Obviously it doesnt affect anything as Solidedge was closing anyways but it's still a bug that I would like to fix.

 

I have narrowed the issue down to the line:

"objAppEvents.AfterWindowActivate += new SolidEdgeFramework.DISEApplicationEvents_AfterWindowActivateEventHandler(objAppEvents_AfterWindowActivate);"

 

In context:

private SolidEdgeFramework.AddIn m_addin;
        private SolidEdgeFramework.Application m_application;
        private SolidEdgeFramework.DISEApplicationEvents_Event objAppEvents;
        
        public void OnConnection(
            object Application,
            SolidEdgeFramework.SeConnectMode ConnectMode,
            SolidEdgeFramework.AddIn AddInInstance)
        {
            ...
            m_application = Application as SolidEdgeFramework.Application;
            // Set Addin's GUI Version
            AddInInstance.GuiVersion = 1;

            try
            {
                // Get a reference to the application events
                objAppEvents = (SolidEdgeFramework.DISEApplicationEvents_Event)m_application.ApplicationEvents;
                
            }
            catch (System.Exception ex)
            {
                WriteOut("Try to set objAppEvents: " + ex.Message, true);
            }

            //define the event to be captured later to update the Program Caption
            objAppEvents.AfterWindowActivate += new SolidEdgeFramework.DISEApplicationEvents_AfterWindowActivateEventHandler(objAppEvents_AfterWindowActivate);

            ...
        }

        private void objAppEvents_AfterWindowActivate(object theWindow) 
        {
            //Any time a window is activated, change the SE caption to show the wanted portion
            SetSECaption();
        }

 

The code is basically to change the caption of each new window that is opened while running Solidedge. When I remove the line I mentioned above the error will go away but so will the ability to change the caption of the windows.

 

Thanks,

Sean Walsh

 

Posted by: Sean Walsh
Post date: 6/21/2012 10:44:16 AM

1 REPLY

Re: SEAddIn AfterWindowActivate

[ Edited ]

I have found a fix, though I don't know if it is proper.

 

I discovered that

objAppEvents.AfterWindowActivate += new SolidEdgeFramework.DISEApplicationEvents_AfterWindowActivateEventHandler(objAppEvents_AfterWindowActivate);

 

is removed by writing

objAppEvents.AfterWindowActivate -= new SolidEdgeFramework.DISEApplicationEvents_AfterWindowActivateEventHandler(objAppEvents_AfterWindowActivate);

 

so I have added the -= version in the OnDisconnect function of the AddIn.

 

Cheers,

Sean Walsh

 

Posted by: Sean Walsh
Post date: 6/21/2012 1:29:54 PM