- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Within my addin, i am presenting a winform to the user by using Myform.Show(); (i am not using .ShowDialog() here)
On the form there is a button that enables the user to make a selection where i am using this code:
UIDocument uidoc = m_commandData.Application.ActiveUIDocument; Document doc = uidoc.Document; this.Hide(); //hides the WinForm try { IList<Element> eleRefs = uidoc.Selection.PickElementsByRectangle("Select by rectangle"); foreach (Element el in eleRefs) { //Do something } } catch (Exception ex) { TaskDialog.Show("Canceled", ex.Message); } uidoc.RefreshActiveView(); this.Show(); //show the winform again this.BringToFront(); //thy to get the winform on top
If i would use the .ShowDialog() instead the of .Show() the revit application would still be frozen and the user is unable to make a selection.
But here is the issue i am facing now:
Once the user finished his selection the Revit application keep beeing the dominant factor and i am unable to get the form to be shown on top of revit again.
Even when i try to cast the this.BringToFront(); on my winform, it Revit that is the front application now.
How should i handle this in a fashionable way?
Should i handle the winform in a different way ?
Edit:
I was thinking i could use this.TopMost = true; to fix this, and it does work, but then i am looking into a way to freeze the Revit GUI in the background (is that possible to do?) so the user cant use revit while the form is still showing (as if it was ShowDialog)
Solved! Go to Solution.