Is there an easy way to determine which is the topmost tabbed document?
Using DTE.ActiveDocument gives me the topmost document (edit buffer), but
won't work when another toolWindow is in Tabbed Document state sitting on
top of the ActiveDocument. In essence, I'd like to know when all
documents/edit bufferes are covered up by a toolwindow that is also tabbed.
I've been getting around this by watching the events from
IVsSelectionEvents. However, so many events are fired when switching
between tabs and other windows in the IDE, that I occasionally catch the
VSConstants.VSSELELEMID.SEID_WindowFrame event when I don't want to.
I know the places when I might need to do the update for which I have been
using IVsSelectionEvents. So if I could just read the text on the tab of
the topmost tabbed document (toolwindow or otherwise), I could handle my
updates more easily than checking through the IVsSelectionEvents.
One more related question:
In IVsSelectionEvents:OnElementValueChanged(uint elementid, object
varValueOld, object varValueNew), when elementid is SEID_WindowFrame, what
kind of old do varValueOld and varValueNew reference. The documentation
mentions that they will be IOleCommandTargets when elementid is
SEID_ResultsList etc. But documents don't say what they will be for
SEID_WindowFram. I tried to cast to IOleWindow, but it did not work.
Thanks,
-DOB-
Boni - 30 Aug 2005 00:35 GMT
Hi David,
I had the same problem and I could find only a workaround to grab VS caption
text (ApplicationObject.MainWindow.Caption) , which seems always to be the
name of an active window.
If you will find better solution please post it into a group.
With best regards,
Boni
> Is there an easy way to determine which is the topmost tabbed document?
> Using DTE.ActiveDocument gives me the topmost document (edit buffer), but
[quoted text clipped - 23 lines]
>
> -DOB-
Dustin Campbell - 30 Aug 2005 05:45 GMT
>Is there an easy way to determine which is the topmost tabbed document?
Try the IVsMonitorSelection service. For example:
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.VSIP;
private IVsWindowFrame
GetActiveDocumentFrame(IVsMonitorSelectionService service)
{
object lValue;
int lRetVal = service.GetCurrentElementValue(SEID_DocumentFrame);
NativeMethods.ThrowOnFailure(lRetVal);
return (lValue as IVsWindowFrame);
}
>One more related question:
>
[quoted text clipped - 4 lines]
>SEID_ResultsList etc. But documents don't say what they will be for
>SEID_WindowFram. I tried to cast to IOleWindow, but it did not work.
Cast to Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame.
--------
Best Regards,
Dustin Campbell
Developer Express, Inc
"Ed Dore [MSFT]" - 31 Aug 2005 18:40 GMT
Hi David,
Dustin's suggestion is definitely the way to go. Regarding the arguments
passed to OnElementValueChanged with the elementid is SEID_WindowFrame, I
did a quick search through the sources and it appears that this a variant
of type VT_UNKNOWN that is the IUnknown of the IVsWindowFrame.
While I haven't tested this in C#, I suspect you can simply cast that
object to an IVsWindowFrame interface.
P.S. The latest documentation drop for the VS SDK doesn't make mention of
this either. But I did submit a bug to the documentation team on this
topic, so hopefully we'll see it addressed in a future documentation drop.
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.