Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modeless dialog - stays on top

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Kevin.Bell
1195 Views, 3 Replies

Modeless dialog - stays on top

Hi,

 

I've created an addon that runs along use the normal user use of revit and allows the user to open certain views - it uses a modeless dialog.

 

This works well, but I've set TopMost property of the dialog to True otherwise I keep losing the dialog behind other windows.

 

The issue is, that with this set, the dialog then stays on top and annoyingly covers other windows.

 

I'd like the window to follow Revit's window, minimise with it and stay the level with it - so when a window covers Revit, it covers the dialog too.

 

I'd appreciate some examples or pointers.

 

Thanks,

3 REPLIES 3
Message 2 of 4
jeremytammik
in reply to: Kevin.Bell

This can be easily fixed by making the Revit main window the owner window of your modeless dialogue, and your modeless dialogue a child of the Revit main window.

 

I implemented the JtWindowHandle class to help achieve this in the past, so you can search The Building Coder for that term to find a number of solutions:

 

https://www.google.com/search?q=JtWindowHandle&as_sitesearch=thebuildingcoder.typepad.com

 

Please note that the Revit API provides official access to the main Revit window nowadays via the UIApplicaiton class MainWindowHandle property:

 

https://www.revitapidocs.com/2020/e28d23a9-6814-1e70-9943-1ee852887dae.htm

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4
Kevin.Bell
in reply to: jeremytammik

Ok, thanks.

Message 4 of 4
jeremytammik
in reply to: Kevin.Bell

My pleasure! 

 

I fleshed out the answer a bit further still and preserved for posterity here:

 

https://thebuildingcoder.typepad.com/blog/2019/09/ui-top-forms-buttons-web-etc.html#2

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community