Is there a way to override this dialog easily?

The custom message is already there, but I'm guessing that my client will be more annoying and will want a translated message.

Can I replace that dialog? This dialog is the one that appear if you thrown an exception from inside a class extension.

enter image description here


Since this has gone unanswered and it looks like a similar issue I had when aborting a delete feature operation, I'll offer my workaround (which I based on something I found on the old Esri forums). It's hacky and you may already be doing this and were looking for a less-hacky method.

Add FindWindow and EndDialog to a class (you might already have a PInvoke class):

public class PInvoke
    public static extern IntPtr FindWindow(String lpszClass, String lpszWindow);

    public static extern int EndDialog(IntPtr hDlg, IntPtr nResult);

Add a timer to your extension class:

private Timer timerDeleteEsriDeleteMessage;

And a property for the timer:

    private Timer TimerRemoveEsriDeleteMessage
            if (timerDeleteEsriDeleteMessage == null)
                timerDeleteEsriDeleteMessage = new Timer();
                timerDeleteEsriDeleteMessage.Interval = 1;
                timerDeleteEsriDeleteMessage.Tick += new EventHandler(OnTimerDeleteEsriDeleteMessageTick);

            return timerDeleteEsriDeleteMessage;

Add the method that actually shuts down the window:

    private void OnTimerDeleteEsriDeleteMessageTick(object timerObject, EventArgs myEventArgs)
        if (((Timer)timerObject).Tag.ToString().Equals("AbortOperation"))
            // Close the dialog with the caption 'Delete'
            IntPtr textBoxHandle = PInvoke.FindWindow(null, "Delete");
            PInvoke.EndDialog(textBoxHandle, (IntPtr)DialogResult.OK);


Now the timer can be started just before a delete operation.

            // I show my dialog here (if I want one)

            // then start the timer, then abort the operation
            this.TimerRemoveEsriDeleteMessage.Tag = "AbortOperation";

I'm thinking this approach may work for the Create Feature Task could not be completed. message (maybe by replacing Delete with Create in the OnTimerDeleteEsriDeleteMessageTick method).

  • Very hacky indeed. I'll give it a try and see how everything comes along. This should work for the save edits dialog too. Nice! – George Silva Jul 19 '11 at 22:36

Officially, I think there's no way you can do that. I was confronted to the same problem while developping a class extension and decided to do it "ESRI official way" and just raise an error. You can always do a hack like Jay described, but since your class extension can be loaded by other clients than ArcMap, you can't know how the client application will handle the error so you should just raise an exception and let the client application handle it.

Quote from http://help.arcgis.com/en/sdk/10.0/arcobjects_cpp/componenthelp/index.html#/IObjectClassEvents_Interface/000s00000610000000/

If you are using the OnCreate, OnDelete or OnChange methods in a class extension to validate edit operations, you should not call AbortEditOperation on the workspace if your logic indicates that the edit operation is invalid. Instead, raise an error which will be propagated to the application that is performing the edit on the class.

It is the responsibility of the editing application that receives the error to abort the edit operation. This is especially true when editing with ArcMap. If you call AbortEditOperation from within the class extension, the ArcMap undo/redo edit stack will become out of sync

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.