i am working on Visual Studio extensions. There is a WindowPane that hosts an Editor Window along with a hierarchy of Window Forms, so from one of these Window Forms i am trying to give focus to the open Editor Window by using the Mouse_Click event. I am trying to do this because, if there is any other Auto Hide ToolWindow(like solution explorer) visible, the Editor Window does not gain focus on Mouse_Click of the hosted Window Form within the Editor Window.
I have tried the following code, but gives a null reference exception on the IVsWindowFrame.
IVsUIShell vsUIShell = (IVsUIShell)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsUIShell));
Guid guid = typeof(SampleEditorPane).GUID;
IVsWindowFrame vsWindowFrame;
int status = vsUIShell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fFindFirst, ref guid, out vsWindowFrame);
if (status != VSConstants.S_OK)
status = vsUIShell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref guid, out vsWindowFrame);
if (status == VSConstants.S_OK)
ErrorHandler.ThrowOnFailure(vsWindowFrame.Show());
Is there any other way i can set focus to the active Editor Window?.
Visual Studio also provides a shortcut ALT + f7 to browser through and select any active Tool Windows.Even if i could implement the above scenario, it would definitely help.
Thanks in advance. Any help is appreciated.