Hi,
I have a vs2012 extension and need to get the main window of devenv.exe. I am getting the correct window handle (I've checked it is the one that is shown by spy++), but the NativeWindow.FromHandle returns null for it. Here is the code snippet:
// returns correct process object
Process p = Process.GetCurrentProcess();
// returns correct window handle
IntPtr mwh = p.MainWindowHandle;
// returns null?!
NativeWindow w = NativeWindow.FromHandle(mwh);
Originally I needed do this from my TFS check-in policy but when I ran into the problem I though this might be something specific to TFS client or Team Explorer window. So I tried to do it another way. I created an extension using VSPackage project template with a menu item added under the Tools menu and tried to get the window object from within the Packag.MenuItemCallback method, but it still returns null.
Any idea what I might be doing wrong?
Thanks,
Gevorg