2

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.

4

2 回答 2

0

对于 VS 2010 SDK,Microsoft 添加了一个新标志 __VSCREATETOOLWIN2.CTW_fDocumentLikeTool

你可以这样使用:

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);
}

这样,当您进行调试时,工具窗口会在“文档井”处持续打开

但是我不得不说这在调试项目时给我们带来了一些问题,避免我们在调试时打开代码文件,比如如果 Visual Studio 文档管理是“块”,这个新标志没有那么多信息......

因此,我们更喜欢挂钩 EnvDTE.DebuggerEvents 并在调试会话开始时显示 ToolWindow(如果隐藏)...

(我们的 ToolWindow 有 MultiInstances = false)

于 2012-01-16T12:18:20.227 回答
0

实施 QueryShowTool

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

使 VSPackage 能够控制是显示还是隐藏工具窗口。当用户切换视图或上下文(例如设计、调试、全屏)时,shell 会调用此方法。

请参阅https://docs.microsoft.com/en-us/visualstudio/extensibility/opening-a-dynamic-tool-window?view=vs-2017

于 2019-02-22T17:50:37.387 回答