How to get the HWND of the browser pane

How to get the HWND of the browser pane

smilinger
Advisor Advisor
627 次查看
0 条回复
1 条消息(共 1 条)

How to get the HWND of the browser pane

smilinger
Advisor
Advisor

Hi, I am trying to get the HWND of the browser pane control, for example I want to get the HWND of the vault browser. I can see them in some tools like Spy++, but I see no way in Inventor API to get them. In the whole Inventor API I can see very few objects support this property.

 

2016-01-11_14-42-27.png

 

Right now what I can think of is using Win32 P/Invoke functions to get it. I can use SetWinEventHook to set a hook to listen to the window creation event of Inventor process, then when I capture the event I can check the Title and class name of the object to decide if it's what I want.

 

[DllImport("user32.dll")]
private static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint  idProcess, uint idThread, uint dwFlags);

This works, however I need to take care of the order in which the Inventor events fires, to decide when to set the hook and when to unhook. This is kind of messy, and sometimes it even depends on the order in which the addins load, for example, my addin may load before or after the vault addin, which has bad impact on my addin.

 

Another way is to use function like FindWindowEx to find the winow, but it would be difficult to distinguish between multiple window instances if you opened a lot of inventor docoments.

 

I am asking is there an easier way to do this, some function in C#, Winform or in WPF, so I can grab the vault browser pane object, for example, from Inventor API, then turn it into a native win32 object or what, and get the HWND of it.

0 个赞
628 次查看
0 条回复
回复 (0)