Is there a way to get the HWnd pointer to the top window of Visual Studio 2010 from a VSIX extension? (I would like to change the title of the window).
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
You can use the EnvDTE API to get the HWnd of main window:
In Visual Studio 2010/ 2012, the main window and part of user controls implemented using WPF. You can immediately get the WPF window of main window and work with it. I wrote the following extension method for this:
Since there are good chances that your VSIX extension will be running in-process with Visual Studio, you should try this:
(Note if you do this too early, you'll get VS Splash screen ...)
I'm assuming you want to do this programatically in C#?
You'll need to define this P/Invoke inside your class:
Then have some code that looks similar to the following:
Doc on Process: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
Doc on P/Invoke: http://msdn.microsoft.com/en-us/library/aa288468%28VS.71%29.aspx
Trying this code on my local, it seems to set the window title, but Visual Studio overwrites it under many conditions: gains focus, enters/leaves debug mode... This could be troublesome.
Note: You can GET the window title straight from the Process object, but you can't set it.