Reply

Cancel saving of document in VB.NET

[ Edited ]

 

HI

 

I'm developing a AddIn for Solid Edge V20.

I want to cancel the OnFileSaveAsUI Event.

The docu sasy:

If you want to cancel the command, return S_OK (or S_FALSE) while returning all the strings as NULL strings so that Solid Edge proceeds to cancel the command without displaying its dialog box

But how can I return a value? The OnFileSaveAsUIEvent is defined as SUB not Function. So I can't return a value.SubOnFileOpenUI ( _

OutAttribute> ByRefFilenameAsString, _

OutAttribute> ByRefAppendToTitleAsString _

)

Or are there some other proerpties I can set?

br

Flo

 

Posted by: Florian Tree
Post date: 2/9/2009 2:19:40 AM

4 REPLIES

RE: Cancel saving of document in VB.NET

[ Edited ]

If you just want to catch the event but not override, you must throw a new System.NotImplementedException. That exception gets mapped under the hood as the return HRESULT. If you do not throw the exception, you are solely responsible for implementing the function.

 

Posted by: Jason Newell
Post date: 2/9/2009 11:25:10 AM

RE: Cancel saving of document in VB.NET

[ Edited ]

OK thanks that works.

And what exception do I have to raise if I want to cancel the Event with S_OK or S_FALSE.

 

 

Posted by: Florian Tree
Post date: 2/9/2009 8:26:23 PM

RE: Cancel saving of document in VB.NET

[ Edited ]

I dont' think you can outright cancel the event. You can either choose to be notified of the event by throwing NotImplementedException or you can not throw any exception in which case you're expected to implement the functionality yourself.

 

Posted by: Jason Newell
Post date: 2/9/2009 9:21:34 PM

RE: Cancel saving of document in VB.NET

[ Edited ]

 

So that means I can be notified about the event. And that's it.

First I wanted to use the Event to generate my own FileNames and show it to the User.

If you return S_OK with valid output strings, Solid Edge proceeds to use the strings accordingly.

Because this does not work I have tried to show my own Save Dialog. This works but after closing my dialog I get the Solid Edge Message "Part1 cannot be saved".

Then I have tried to hide the message with "application.DisplayAlerts = False". But this takes no effect.

So is there a way in VB.NET to handle the Event by myself and show my own dialog box are show an own created filename in the original Dialog Box?

 

Posted by: Florian Tree
Post date: 2/9/2009 10:30:51 PM