The right way to show modal and modeless dialogs in AutoCAD using .NET
My manager is currently sailing back from Honolulu to San Francisco, after his boat came 2nd in its division in the 2008 Pacific Cup (congratulations, Jim! :-), so I'm spending more time on management-related activities than I would normally. Which means I'm getting less time to spend on the fun stuff, such as researching blog posts: I'm plundering what I can from my email archives, but my output may feel a little thin over the next week or two.
Here's some information from an internal discussion that I thought might be of general interest.
Why is it important to use Application.ShowModalDialog() or Application.ShowModelessDialog()? The documentation for both these commands says "You must use this method instead of Form.Show[Dialog], which may lead to unexpected behavior." Any pointers as to what the "unexpected behavior" might be?
Here's the answer, provided by a member of the AutoCAD Engineering team:
There are a number of reasons to use Application.Show[Modal/Modeless]Dialog() rather than Form.Show[Dialog]:
- Dialogs will automatically pick up the icon of the host product
- Dialog size and position will be persisted automatically
- Other floating AutoCAD windows (e.g. the Properties palette) will be disabled, as needed
- The DIASTAT system variable will be set properly with the exit status of the dialog