VS SDK: ToolWindowPane hides when debugging

523 views Asked by At

I used the VS 2010 SDK to create and show a custom ToolWindowPane with a WPF control as content. I create a new instance and show it each time a Tool menu item is clicked (the ProvideToolWindow attribute has MultiInstances = true).

When the user attaches the debugger (e.g., hits F5 while in C# project) my ToolWindowPane suddenly hides. I'd like to make sure my tool window is always visible while open, no matter what context the user is in. Is there a way I can enforce that?

I've tried using the ProvideToolWindowVisibility attribute but that automatically shows a new instance of my tool window rather than keeping a remaining one open.

2

There are 2 answers

0
Jesus Salas On

For VS 2010 SDK Microsoft added a new flag __VSCREATETOOLWIN2.CTW_fDocumentLikeTool

You can use this way:

public override void OnToolWindowCreated()
{
    IVsWindowFrame windowFrame = Frame as IVsWindowFrame;

    object varFlags;

    windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, out varFlags);
    int flags = (int)varFlags | (int)__VSCREATETOOLWIN2.CTW_fDocumentLikeTool;
    windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, flags);
}

This way Tool Window persist open at "Document Well" when you go Debugging

However I have to say this give us some problems when debugging projects, avoiding us to open code files while debugging, like if Visual Studio document management was 'block', there are not so much information for this new flag...

So we preferred to hook to EnvDTE.DebuggerEvents and show the ToolWindow if hide when a debugging session start...

(our ToolWindow has MultiInstances = false)

0
r3m0t On

Implement QueryShowTool

public:
 int QueryShowTool(Guid % rguidPersistenceSlot, System::UInt32 dwId, [Runtime::InteropServices::Out] int % pfShowTool);

Enables the VSPackage to control whether to show or hide the tool window. The shell calls this method when the user switches views or contexts, for example Design, Debugging, Full Screen.

See https://learn.microsoft.com/en-us/visualstudio/extensibility/opening-a-dynamic-tool-window?view=vs-2017