Active document window handle

Active document window handle

prakash.muthu
Advocate Advocate
378 Views
4 Replies
Message 1 of 5

Active document window handle

prakash.muthu
Advocate
Advocate

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.

0 Likes
379 Views
4 Replies
Replies (4)
Message 2 of 5

Moustafa_K
Collaborator
Collaborator

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
0 Likes
Message 3 of 5

prakash.muthu
Advocate
Advocate

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? 

0 Likes
Message 4 of 5

prakash.muthu
Advocate
Advocate

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

0 Likes
Message 5 of 5

Moustafa_K
Collaborator
Collaborator

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
0 Likes