AxHost クラスとは? わかりやすく解説

AxHost クラス

ActiveX コントロールラップし、完全な機能備えた Windows フォーム コントロールとしてそのコントロール公開します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public MustInherit Class
 AxHost
    Inherits Control
    Implements ISupportInitialize, ICustomTypeDescriptor
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
public abstract class AxHost : Control, ISupportInitialize,
 ICustomTypeDescriptor
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
public ref class AxHost abstract : public
 Control, ISupportInitialize, ICustomTypeDescriptor
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
public abstract class AxHost extends Control
 implements ISupportInitialize, ICustomTypeDescriptor
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
public abstract class AxHost extends
 Control implements ISupportInitialize, ICustomTypeDescriptor
解説解説

通常AxHost クラス直接使用しません。Windows フォーム ActiveX コントロール インポータ (Aximp.exe) を使用してAxHost拡張するラッパー生成できます

ActiveX コントロール インポータは、AxHost派生クラス生成してライブラリ ファイル (DLL) にコンパイルます。これは、アプリケーション参照として追加できます。または、ActiveX コントロール インポータに /source スイッチ付けて実行すると、AxHost派生クラスC# ファイル生成されます。生成されC# ファイル必要に応じて変更しライブラリ ファイルに再コンパイルできます

メモメモ

ActiveX コントロール中に.NET Framework定義されている名前と同じ名前のメンバがある場合AxHost派生クラス作成時にActiveX コントロール インポータによって、これらのメンバプレフィックス "Ctl" が付けられます。たとえば、ActiveX コントロールに "Layout" という名前のメンバがあるとします.NET Framework には Layout という名前のイベントが既にあるため、AxHost派生クラス内では "CtlLayout" に名前が変更されます。

AxHost クラスの共通プロパティ多くは、基になる ActiveX コントロールがそれらのプロパティ公開している場合だけに有効であり、使用できます。共通プロパティには、BackColorCursorFontText などがあります

使用例使用例

Microsoft Masked Edit ActiveX コントロールラップする AxHost派生クラスコンストラクタ、SetAboutBoxDelegate メソッド、および AttachInterfaces メソッドオーバーライドするコード例次に示します。このコードは、MSMask32.ocx ファイル上で /source スイッチ使用して AxImp.exe を実行し編集対象となるラッパー クラス生成することで、生成されるソース コード作成済みであることを前提としています。AxImp.exe の出力言語C# だけなので、ここでは C# 構文コードだけを示します

public AxMaskEdBox()
    :
  base("c932ba85-4374-101b-a56c-00aa003668dc") //
 The ActiveX control's class identifier.
{
    // Make the AboutBox method the about box delegate.
    this.SetAboutBoxDelegate(new AboutBoxDelegate(AboutBox));
}

public virtual void AboutBox()
{
    // If the instance of the ActiveX control is null when the AboutBox
 method 
    // is called, raise an InvalidActiveXStateException exception.
    if ((this.ocx == null))
    {
        throw new System.Windows.Forms.AxHost.InvalidActiveXStateException(
          "AboutBox", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke);
    }
    // Show the about box if the ActiveX control has one.
    if (this.HasAboutBox)
    {
        this.ocx.AboutBox();
    }
}

protected override void AttachInterfaces()
{
    try
    {
        // Attach the IMSMask interface to the ActiveX control.
        this.ocx = ((MSMask.IMSMask)(this.GetOcx()));
    }
    catch (System.Exception ex)
    {
        System.Console.WriteLine(ex.Message);
    }
}
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
        System.Windows.Forms.AxHost
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からAxHost クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からAxHost クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からAxHost クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「AxHost クラス」の関連用語

AxHost クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



AxHost クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS