Form freezes after showing, hiding and re-displaying

Form freezes after showing, hiding and re-displaying

williamdepadua
Enthusiast Enthusiast
332 Views
2 Replies
Message 1 of 3

Form freezes after showing, hiding and re-displaying

williamdepadua
Enthusiast
Enthusiast

Hello, follow the schematic code. 

 

<Autodesk.autocad.rutime.commandmethod("teste")>_

Public Sub open()

 

ShowModalDialog(Myform)

 

End Sub

 

Private Sub btClick()

 

Me.hide()

.

.

.

 

If ...... then

 

ShowModalDialog(Myform)

Exit sub

 

End if

 

End sub

 

I view my form in a restricted way, click on a button that hides the form using myform.hide, and ask me to select an entity. If I deselect it, it should display the form again. This works the first time I cancel, but if I do it one more time, the form freezes. The sequence would be to display form, click button, esc, click button, and esc. Freezes.

0 Likes
Accepted solutions (1)
333 Views
2 Replies
Replies (2)
Message 2 of 3

Norman_Yuan
Mentor
Mentor
Accepted solution

It is known issue that calling Form.Hide() with a modal form in AutoCAD plugin is problematic.

 

When user needs to interact with AutoCAD editor from a modal UI, as you intend to do, you should use EditorUserInteraction object, by calling

 

var editor=Application.DocumentManager.MdiActiveDocument.Editor;

// This hide the modal form automatically

using (edit.StartUserInteraction([modalForm]))

{

   // Do selection in AutoCAD editor here

   // When the using{...} ends, the modal form shows back automatically

}

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

williamdepadua
Enthusiast
Enthusiast

Great, it worked. Thank you

0 Likes