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: 

Active document window handle

4 REPLIES 4
Reply
Message 1 of 5
prakash.muthu
284 Views, 4 Replies

Active document window handle

Hi,

 

Looking for an API to get active window handle of current document in display. Trying to find the highlighted area view window handle.

prakashmuthu_0-1721642350980.png

Thank you.

4 REPLIES 4
Message 2 of 5
Moustafa_K
in reply to: prakash.muthu

using UIframework.dll (part of Revit installation) and 

using Xceed.Wpf.AvalonDock.dll (part of Revit installation) and 

using Microsoft.VisualStudio.Utilities nuget

 

you can get that via this code:

 var docControl = MainWindow.getMainWnd().FindDescendant<LayoutDocumentControl>();

 

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
Message 3 of 5
prakash.muthu
in reply to: Moustafa_K

Getting error on using above code.


'MainWindow' does not contain a definition for 'FindDescendant' and no accessible extension method 'FindDescendant' accepting a first argument of type 'MainWindow' could be found (are you missing a using directive or an assembly reference?)

Do i need to add more references? 

Message 4 of 5
prakash.muthu
in reply to: Moustafa_K

Thank you Mustafa. Now able to get the control. Further how to get the window handle and mapping it with specific document.

Message 5 of 5
Moustafa_K
in reply to: prakash.muthu

you can get the handle using PresentationSource

 

var hwndSource = PresentationSource.FromVisual(docControl) as HwndSource;
var handle = hwndSource.Handle;

 

 

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1

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

Post to forums  

Autodesk Design & Make Report