From: "Dmitriy Lapshin [C# / .NET MVP]
Subject: Dealing with Dynamic Help for an add-in's tool window
Date: Thu, 9 Oct 2003 18:24:36 +0300
Newsgroups:
microsoft.public.vstudio.helpauthoringI am trying to add Dynamic
Help integration to an add-in's tool window. Kudos to Rob Chandler and his
website, I have managed to get it more or less working. I am however
observing quite a strange effect my toolwindow has on the Dynamic Help.
The toolwindow adds an F-keyword to its ContextAttributes collection. The
keyword is successfully looked up in the help collection and listed in the
Dynamic Help window. But, I would expect this keyword to go away from
Dynamic Help whenever I switch off the toolwindow and to appear again when I
go back to the toolwindow. Alas, the keyword seems to be displayed whichever
toolwindow is currently active. After meditating on it for a while, I have
thought this might be logical - you can access help on the toolwindow as
long as you have it visible and when you are currently focused on
toolwindows - and not on code editing, for example. But I would like to
ensure this is not an error caused by incorrect manipulation with
ContextAttributes.
Thanks a lot in advance!
--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP] |
From: Marc H. Young [MSFT]
Organization: Microsoft
Date: Wed, 15 Oct 2003 18:20:31 GMT
Newsgroups:
microsoft.public.vstudio.helpauthoringI asked one of our devs about
this, and this was his response:
It depends on how the context attributes are set. Is he setting them with
DTE.ContextAttributes or Window.ContextAttributes? If they are being set
with DTE.ContextAttributes, then they should be global and affect
everything. If they are being set with Window.ContextAttributes, then the
attribute should also be available when the window is active. It also may
make a difference on what kind of window he set the attributes on. I am not
sure of the algorithm used by help, but I think that it will keep the
attributes of the active document active all the time. |
| OK, here's what I figured out for tool windows. For
illustrative purposes, let's say that I want Dynamic Help to show topics for
the Properties window whenever someone selects my tool window. I can do that
by setting the same ContextAttribute values for my tool window that are used
by the Properties window. So what are the Property window's
ContextAttributes? In an add-in, I can display the ContextAttribute
settings for the Properties window by using the following code: string
attrs = "";
EnvDTE.Window propWin =
this.dte.Windows.Item(EnvDTE.Constants.vsWindowKindProperties);
foreach (EnvDTE.ContextAttribute attr in propWin.ContextAttributes)
{
attrs += attr.Name + " =" + Environment.NewLine;
Array values = (Array)attr.Values;
foreach (string val in values)
{
attrs += " " + val + Environment.NewLine;
}
}
MessageBox.Show(attrs);
When I run this code, the one setting I see for the Properties window has
the name "Keyword" and a value of "VS.Properties". If I select the
Properties window, follow the "Properties Window" link displayed by Dynamic
Help, and view the source for that topic, I find the following F-Index
keyword entry:
<MSHelp:Keyword Index="F" Term="vs.properties"/>
which is what I would expect to find.
So, if I want the "Properties Window" topic to show up in the Dynamic Help
window when I select my tool window, I can use code like the following to
associate the previous keyword with my tool window:
this.toolWindow.ContextAttributes.Add("keyword", "vs.properties",
vsContextAttributeType.vsContextAttributeLookupF1);
where this.toolWindow is a reference to a tool window created by
EnvDTE.DTE.Windows.CreateToolWindow(). I assume that by adding this keyword
to the DTE.ContextAttributes collection that the "Properties Window" topic
will show up no matter what UI element is selected in the IDE.
Let me know if I've left out any important details.
Marc Young [MSFT] |