DialogPlugin Closing Event

DialogPlugin Closing Event

Anonymous
Not applicable
814 Views
6 Replies
Message 1 of 7

DialogPlugin Closing Event

Anonymous
Not applicable

Hi all,

I need to avoid a Dialog to be closed if there is no some attributes correctly informed.

Tricking with the ModeChanging events I can control if the Cancel button is pressed, but if the dialog is forced to be closed with the native (X) close form button, I cannot prevent it to close.

I have tried to do a Me.Dialog.Show() in the Closing event but the dialog closes anyway.

 

Any ideas on how to avoid to close or how to re open it again?

 

Thanks in advance!

 

Francisco J. Barrero

GIS Developer

0 Likes
815 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Hi Francisco,

 

 

have your tried this in the closing event routine:

 

 

e.Cancel = true;

 

 

MSDN:

https://msdn.microsoft.com/en-us/library/system.windows.forms.form.closing(v=vs.110).aspx

 

Rob

 

 

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hi Robert,

 

That was my idea on the first time.

But the DialogPlugin Closing event receives EventArgs insted CancelEventArgs.

I have even tried a conversion to CancelEventArgs but the point is that the "e" parameter is nothing.

 

Any other ideas? 😞

0 Likes
Message 4 of 7

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

I also think "e.Cancel = True" should do the trick.

If you get any other events when the X-button is pressed that this might depend more in the initialization- or form-loading code.

 

I would suggest you create a minimalistic project, just one (empty) form, the loading within AutoCAD and if that happens again with that code then upload the solution here and we will take a look into it.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 7

Anonymous
Not applicable

The source code is quite simple, note that it's a DialogPlugin not a DocumentPlugin:

 

Imports Autodesk.Map.IM.Data
Imports Autodesk.Map.IM.Forms
Imports System.ComponentModel

 

Public Class TestDLG Inherits Autodesk.Map.IM.Forms.DialogPlugIn

 

Private Sub BaixaDLG_Closing(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Closing

  'e.Cancel()

  'CType(e, System.ComponentModel.CancelEventArgs).Cancel()

End Sub

 

End Class

 

First commented Cancel fails since e is not a System.ComponentModel.CancelEventArgs

Segon commented Cancel fails since e is nothing when the event fires.

 

Hope this helps to put some light on the solution.

 

 

0 Likes
Message 6 of 7

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

Is it necessary to use the IM.xx.DialogPlugin inheritance? If possible can you work with default Windows Forms?

When/how/what code do you use to initialize and show the dialog?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 7 of 7

Anonymous
Not applicable

Hi Alfred,

 

I'm trying to control the behaviour of an industry model feature class form. I think I need to use a DialogPlugin inheritance.

The DialogPlugin is initialized by Map for this form, I have its definition on the tbp file.

 

  <DialogPlugIn ClassName="TestDLG " Name="MY_FEATURE_CLASS" />

 

Your help is appreciated.

 

 

0 Likes