IVsUIShellOpenDocument.OpenDocumentViaProject taskbar issue RRS feed

  • Question

  • Hi,

    I have a strange issue regarding documents that are opened via IVsUIShellOpenDocument.OpenDocumentViaProject. In brief, I am using the IVsUIShellOpenDocument to open a document and then I use this document to host inside my user control. This works great except that now I have an issue when user tries to open the same document via solution explorer - icon and window frame title are shown on the taskbar, although there is no visible window.

    So, here's what I am doing:

    First I call:

    IVsUIHierarchy hierarchy = null;
    uint itemid;
    Guid logicalView = Guid.Empty;
    IVsWindowFrame windowFrame;
    Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp;
    ErrorHandler.ThrowOnFailure(shellOpenDoc.OpenDocumentViaProject(TargetFile, ref logicalView, out psp, out hierarchy, out itemid, out windowFrame));

    This will give me the correct IVsWindowFrame object which I then associate with my parent window:

    var window = VsShellUtilities.GetWindowObject(VisualStudioServices.Frame);
    windowFrame.SetProperty((int)__VSFPROPID2.VSFPROPID_ParentHwnd, window.HWnd);
    windowFrame.SetProperty((int)__VSFPROPID2.VSFPROPID_ParentFrame, VisualStudioServices.Frame);

    In this way any "navigation" done by VS will be correctly dispatched to my user control, but there is a catch, now if someone double-clicks on the same document in the solution explorer an icon with the window frame title will be shown in the windows taskbar. It would be like document is explicitly opened in the VS (not docked inside the VS). So, now, for every open document that is hosted by my user control if user double-clicks the solution explorer (or in "find all references" window for instance), there will be a new taskbar item. Is there a way to prevent this? 

    I have tried to call IVsWindowFrame.Hide function, but it won't hide the taskbar item, but if I call IVsWindowFrame.Close function, it will close the item from the taskbar but in that case, my hosted document is no longer associated to the window frame of my usercontrol and if user now double clicks on the solution explorer a new separate standalone document will be opened of the same file. So, the question is, what is the correct way to associate IVsWindowFrame to given parent (with windowFrame.SetProperty and __VSFPROPID2.VSFPROPID_ParentFrame property)? Is there any additional steps needed to perform before associating child's window frame to parent?


    • Edited by Jinnee2000 Friday, September 9, 2016 10:53 AM
    Friday, September 9, 2016 10:51 AM

All replies

  • IVsWindowFrame.Hide which is function about hides a window instead of taskbar item.
    Tuesday, October 11, 2016 6:22 AM
  • Hi,

    Did you resolve that problem? I have the similar issue, after activating editor I see new window in taskbar. In general I want to host the VS document in my WPF control via IWpfTextViewHost interface but setting VSFPROPID_ParentHwnd and VSFPROPID_ParentFrame does not work as expected.

    Mstislav Sakidon

    Wednesday, September 25, 2019 9:45 PM