IHelpService インターフェイス
アセンブリ: System (system.dll 内)


デザイン時環境には、ユーザーが F1 キーを押したときに関連するヘルプ トピックを検索するヘルプ システムが用意されています。このヘルプ システムは、ヘルプが要求された場合に関連するトピックを指定するために使用する、現在のコンテキスト キーワードのセットを維持します。既定では、キーワードはデザイン時環境で選択されたクラス オブジェクトやオブジェクトのプロパティに関連付けられます。コンポーネントやプロパティの既定のキーワードは、そのクラスやプロパティの完全修飾名です。また特定のキーワードは、複数のオブジェクトが選択されたときなど、特定のモードにも関連付けられています。カスタム ヘルプ コレクションが外部ヘルプ プロバイダに対応して構成され、デザイン時環境で統合されている場合、ドキュメント プロバイダは、特定のコンポーネントのクラスやプロパティのトピックを、その項目の完全修飾型名や完全修飾メンバ名で構成されたキーワードに関連付けることができます。
IHelpService を使用すると、ShowHelpFromKeyword メソッドを使用して、指定したキーワードでヘルプ サービスを呼び出したり、ShowHelpFromUrl メソッドを使用して、指定した URL からヘルプ トピックを呼び出すことができます。
また IHelpService を使用して、デザイン時にヘルプ キーワードの追加や削除を行うこともできます。デザイン時にコンポーネントやプロパティを選択すると、選択対象の完全修飾型名や完全修飾メンバ名で構成された既定の目次キーワードが設定され、以前に選択されていた (もう選択されていない) コンポーネントやプロパティのキーワードは削除されます。
ヘルプ システムは、カスタム ヘルプ キーワードを自動的に削除しないため、使用しなくなったカスタム キーワードは明示的に削除する必要があります。ISelectionService インターフェイスで定義されるイベントを監視すると、コンポーネントの選択状態が変更されるタイミングを判断できます。これらのイベントに基づいて、コンポーネントが選択されたときにそのコンポーネントのヘルプ コンテキスト属性を追加し、選択内容からコンポーネントが外されたときにヘルプ コンテキスト属性を削除できます。

IHelpService を使用して、該当するコントロールのヘルプ コンテキスト属性の追加や削除を行うコード例を次に示します。この例を使用するには、クラス ライブラリにコンパイルし、コントロールのインスタンスを Form に追加する必要があります。デザイン ビューで、コンポーネントを選択し、F1 キーを押すと、現在のヘルプ コンテキスト キーワードに基づいて関連するヘルプ トピックが検索されます。コンポーネントを右クリックすると、Add IHelpService Help Keyword や Remove IHelpService Help Keyword の名前の付いた 2 つのカスタム DesignerVerb コマンドを含むショートカット メニューが表示されます。これらのコマンドを使用して、F1 キーを押したときに IHelpService トピックを表示する値 "IHelpService" のヘルプ コンテキスト キーワードの追加や削除を行うことができます。
Imports System Imports System.ComponentModel Imports System.ComponentModel.Design Imports System.Drawing Imports System.IO Imports System.Windows.Forms Imports System.Windows.Forms.Design Namespace IHelpServiceSample Public Class HelpDesigner Inherits System.Windows.Forms.Design.ControlDesigner Public Sub New() End Sub 'New Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection Get Return New DesignerVerbCollection(New DesignerVerb() {New DesignerVerb("Add IHelpService Help Keyword", AddressOf Me.addKeyword), New DesignerVerb("Remove IHelpService Help Keyword", AddressOf Me.removeKeyword)}) End Get End Property Private Sub addKeyword(ByVal sender As Object, ByVal e As EventArgs) Dim hs As IHelpService = CType(Me.Control.Site.GetService(GetType(IHelpService)), IHelpService) hs.AddContextAttribute("keyword", "IHelpService", HelpKeywordType.F1Keyword) End Sub 'addKeyword Private Sub removeKeyword(ByVal sender As Object, ByVal e As EventArgs) Dim hs As IHelpService = CType(Me.Control.Site.GetService(GetType(IHelpService)), IHelpService) hs.RemoveContextAttribute("keyword", "IHelpService") End Sub 'removeKeyword End Class 'HelpDesigner <Designer(GetType(HelpDesigner))> _ Public Class HelpTestControl Inherits System.Windows.Forms.UserControl Public Sub New() Me.Size = New Size(320, 100) Me.BackColor = Color.White End Sub 'New Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) Dim brush As New SolidBrush(Color.Blue) e.Graphics.DrawString("IHelpService Example Designer Control", New Font(FontFamily.GenericMonospace, 10), brush, 5, 5) e.Graphics.DrawString("Right-click this component for", New Font(FontFamily.GenericMonospace, 8), brush, 5, 25) e.Graphics.DrawString("add/remove Help context keyword commands.", New Font(FontFamily.GenericMonospace, 8), brush, 5, 35) e.Graphics.DrawString("Press F1 while this component is", New Font(FontFamily.GenericMonospace, 8), brush, 5, 55) e.Graphics.DrawString("selected to raise Help topics for", New Font(FontFamily.GenericMonospace, 8), brush, 5, 65) e.Graphics.DrawString("the current keyword or keywords", New Font(FontFamily.GenericMonospace, 8), brush, 5, 75) End Sub 'OnPaint End Class 'HelpTestControl End Namespace 'IHelpServiceSample
using System; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing; using System.IO; using System.Windows.Forms; using System.Windows.Forms.Design; namespace IHelpServiceSample { public class HelpDesigner : System.Windows.Forms.Design.ControlDesigner { public HelpDesigner() { } public override System.ComponentModel.Design.DesignerVerbCollection Verbs { get { return new DesignerVerbCollection( new DesignerVerb[] { new DesignerVerb("Add IHelpService Help Keyword", new EventHandler(this.addKeyword)) , new DesignerVerb("Remove IHelpService Help Keyword", new EventHandler(this.removeKeyword)) } ); } } private void addKeyword(object sender, EventArgs e) { IHelpService hs = (IHelpService) this.Control.Site.GetService(typeof(IHelpService)); hs.AddContextAttribute("keyword", "IHelpService", HelpKeywordType.F1Keyword); } private void removeKeyword(object sender, EventArgs e) { IHelpService hs = (IHelpService) this.Control.Site.GetService(typeof(IHelpService)); hs.RemoveContextAttribute("keyword", "IHelpService"); } } [Designer(typeof(HelpDesigner))] public class HelpTestControl : System.Windows.Forms.UserControl { public HelpTestControl() { this.Size = new Size(320, 100); this.BackColor = Color.White; } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Brush brush = new SolidBrush(Color.Blue); e.Graphics.DrawString("IHelpService Example Designer Control", new Font( FontFamily.GenericMonospace, 10 ), brush, 5, 5); e.Graphics.DrawString("Right-click this component for", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 25); e.Graphics.DrawString("add/remove Help context keyword commands.", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 35); e.Graphics.DrawString("Press F1 while this component is", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 55); e.Graphics.DrawString("selected to raise Help topics for", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 65); e.Graphics.DrawString("the current keyword or keywords", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 75); } } }
#using <System.Windows.Forms.dll> #using <System.Drawing.dll> #using <System.Design.dll> #using <System.dll> using namespace System; using namespace System::ComponentModel; using namespace System::ComponentModel::Design; using namespace System::Drawing; using namespace System::IO; using namespace System::Windows::Forms; using namespace System::Windows::Forms::Design; public ref class HelpDesigner: public System::Windows::Forms::Design::ControlDesigner { public: HelpDesigner(){} property System::ComponentModel::Design::DesignerVerbCollection^ Verbs { virtual System::ComponentModel::Design::DesignerVerbCollection^ get() override { array<DesignerVerb^>^temp0 = {gcnew DesignerVerb( "Add IHelpService Help Keyword",gcnew EventHandler( this, &HelpDesigner::addKeyword ) ),gcnew DesignerVerb( "Remove IHelpService Help Keyword",gcnew EventHandler( this, &HelpDesigner::removeKeyword ) )}; return gcnew DesignerVerbCollection( temp0 ); } } private: void addKeyword( Object^ /*sender*/, EventArgs^ /*e*/ ) { IHelpService^ hs = dynamic_cast<IHelpService^>(this->Control->Site->GetService( IHelpService::typeid )); hs->AddContextAttribute( "keyword", "IHelpService", HelpKeywordType::F1Keyword ); } void removeKeyword( Object^ /*sender*/, EventArgs^ /*e*/ ) { IHelpService^ hs = dynamic_cast<IHelpService^>(this->Control->Site->GetService( IHelpService::typeid )); hs->RemoveContextAttribute( "keyword", "IHelpService" ); } }; [Designer(HelpDesigner::typeid)] public ref class HelpTestControl: public System::Windows::Forms::UserControl { public: HelpTestControl() { this->Size = System::Drawing::Size( 320, 100 ); this->BackColor = Color::White; } protected: virtual void OnPaint( System::Windows::Forms::PaintEventArgs^ e ) override { Brush^ brush = gcnew SolidBrush( Color::Blue ); e->Graphics->DrawString( "IHelpService Example Designer Control", gcnew System::Drawing::Font( FontFamily::GenericMonospace,10 ), brush, 5, 5 ); e->Graphics->DrawString( "Right-click this component for", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), brush, 5, 25 ); e->Graphics->DrawString( "add/remove Help context keyword commands.", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), brush, 5, 35 ); e->Graphics->DrawString( "Press F1 while this component is", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), brush, 5, 55 ); e->Graphics->DrawString( "selected to raise Help topics for", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), brush, 5, 65 ); e->Graphics->DrawString( "the current keyword or keywords", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), brush, 5, 75 ); } };
package IHelpServiceSample; import System.*; import System.ComponentModel.*; import System.ComponentModel.Design.*; import System.Drawing.*; import System.IO.*; import System.Windows.Forms.*; import System.Windows.Forms.Design.*; public class HelpDesigner extends System.Windows.Forms.Design.ControlDesigner { public HelpDesigner() { } //HelpDesigner /** @property */ public System.ComponentModel.Design.DesignerVerbCollection get_Verbs() { return new DesignerVerbCollection(new DesignerVerb[] { new DesignerVerb("Add IHelpService Help Keyword", new EventHandler(this.AddKeyword)), new DesignerVerb( "Remove IHelpService Help Keyword", new EventHandler( this.RemoveKeyword)) }); } //get_Verbs private void AddKeyword(Object sender, EventArgs e) { IHelpService hs = (IHelpService)(this.get_Control().get_Site(). GetService(IHelpService.class.ToType())); hs.AddContextAttribute("keyword", "IHelpService", HelpKeywordType.F1Keyword); } //AddKeyword private void RemoveKeyword(Object sender, EventArgs e) { IHelpService hs = (IHelpService)(this.get_Control().get_Site(). GetService(IHelpService.class.ToType())); hs.RemoveContextAttribute("keyword", "IHelpService"); } //RemoveKeyword } //HelpDesigner /** @attribute Designer(HelpDesigner.class) */ public class HelpTestControl extends System.Windows.Forms.UserControl { public HelpTestControl() { this.set_Size(new Size(320, 100)); this.set_BackColor(Color.get_White()); } //HelpTestControl protected void OnPaint(System.Windows.Forms.PaintEventArgs e) { Brush brush = new SolidBrush(Color.get_Blue()); e.get_Graphics().DrawString("IHelpService Example Designer Control" , new Font(FontFamily.get_GenericMonospace(), 10), brush, 5, 5); e.get_Graphics().DrawString("Right-click this component for", new Font(FontFamily.get_GenericMonospace(), 8), brush, 5, 25); e.get_Graphics().DrawString("add/remove Help context keyword commands." , new Font(FontFamily.get_GenericMonospace(), 8), brush, 5, 35); e.get_Graphics().DrawString("Press F1 while this component is", new Font(FontFamily.get_GenericMonospace(), 8), brush, 5, 55); e.get_Graphics().DrawString("selected to raise Help topics for", new Font(FontFamily.get_GenericMonospace(), 8), brush, 5, 65); e.get_Graphics().DrawString("the current keyword or keywords", new Font(FontFamily.get_GenericMonospace(), 8), brush, 5, 75); } //OnPaint } //HelpTestControl

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


IHelpService メソッド

名前 | 説明 | |
---|---|---|
![]() | AddContextAttribute | コンテキスト属性をドキュメントに追加します。 |
![]() | ClearContextAttributes | ドキュメントから既存のコンテキスト属性をすべて削除します。 |
![]() | CreateLocalContext | ローカル IHelpService を作成し、サブコンテキストを管理します。 |
![]() | RemoveContextAttribute | 以前に追加したコンテキスト属性を削除します。 |
![]() | RemoveLocalContext | CreateLocalContext を使用して作成したコンテキストを削除します。 |
![]() | ShowHelpFromKeyword | 指定したキーワードに対応するヘルプ トピックを表示します。 |
![]() | ShowHelpFromUrl | 指定した URL に対応するヘルプ トピックを表示します。 |

IHelpService メンバ
デザイン時に、ヘルプ トピックを表示し、ヘルプ キーワードの追加と削除を行うためのメソッドを提供します。
IHelpService データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | AddContextAttribute | コンテキスト属性をドキュメントに追加します。 |
![]() | ClearContextAttributes | ドキュメントから既存のコンテキスト属性をすべて削除します。 |
![]() | CreateLocalContext | ローカル IHelpService を作成し、サブコンテキストを管理します。 |
![]() | RemoveContextAttribute | 以前に追加したコンテキスト属性を削除します。 |
![]() | RemoveLocalContext | CreateLocalContext を使用して作成したコンテキストを削除します。 |
![]() | ShowHelpFromKeyword | 指定したキーワードに対応するヘルプ トピックを表示します。 |
![]() | ShowHelpFromUrl | 指定した URL に対応するヘルプ トピックを表示します。 |

Weblioに収録されているすべての辞書からIHelpServiceを検索する場合は、下記のリンクをクリックしてください。

- IHelpServiceのページへのリンク