Hi Matus,
Hiding Modal Forms during User Interaction
This is a unique requirement that AutoCAD based developers face very often. The scenario: A modal form is displayed with some information about one’s application. A modal form as many are aware does not allow user interaction with the AutoCAD editor as long as it is displayed. The modal form has to be closed before the control returns to the AutoCAD editor. This however is not always possible; we may want to temporarily access the AutoCAD editor (to say pick a point or select an entity) and return back to our Modal form to continue with our application’s workflow.
A developer who has developed a generic .NET application before may be tempted to just “hide” the .NET form and “restore” it when we are done with the AutoCAD editor. This however causes a set of problems subtle enough to escape even the most experienced developers at first glance. For instance, a developer who “hides the form” also has to make sure, the AutoCAD editor is “activated” and the focus is set to it. That means extra code. However this is a very small problem compared to the real issue. Because of the way AutoCAD is architected, one has to be very careful about how AutoCAD switches between UI elements and how code that access AutoCAD resources (like the editor and entities) from a UI element does it. Not doing it right could mean an AutoCAD crash (we have seen that before!) with no clue as to what caused it.
The AutoCAD .NET API makes it very simple and easy to implement user interaction without the need to worry about these issues. Specifically, the AutoCAD .NET class “EditorUserInteraction” helps us in wrapping up all the functionality that one needs to perform safe switching between a modal form and the AutoCAD editor. The typical usage of this code would look like this:
using (EditorUserInteraction edUsrInt = ed.StartUserInteraction(this)) { // Code to add a couple of entities to AutoCAD PromptPointOptions prPtOpts = new PromptPointOptions("\nPlease select a point to place the ellipse:"); PromptPointResult prPtRes = ed.GetPoint(prPtOpts); Utilities.AddEllipse(prPtRes.Value); prPtOpts.Message = "\nPlease select a point to place the circle:"; prPtRes = ed.GetPoint(prPtOpts); Utilities.AddCircle(prPtRes.Value); ed.WriteMessage("\nAdded an Entity"); edUsrInt.End(); // End the UserInteraction. this.Focus(); }
The object “ed” represents the AutoCAD editor.
I copied this from a class from Autodesk University, here's the link to that class:
http://au.autodesk.com/?nd=class&session_id=5055
Hope this helps to sovle your problem.
Kind regards.
Irvin
thanks for trying to help, but this is not what i want to do
I'm not hiding the first form to get some user interaction in autocad, but to open another form and i don't want to have them both displayed, after user does his job on the other form, that one is closed and he gets back to the first form
I know about that method, that you mention, but i have no problems using me.hide / me.show for getting user input, it only occurs, when i want to show another form
Old post but I'll reply.
I don't know if this is an option but I've found that closing the form doesn't result in the flash
me.close
yeah, that might be, but at some point later, i want to show the first form again, so I'm not closing it, just hiding
I had the same problem. I just reload the form with data from storage variables.
It's probably not that difficult in my case though.