Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

AxHost.SetAboutBoxDelegate Method

Calls the ShowAboutBox method to display the ActiveX control's About dialog box.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
member SetAboutBoxDelegate : 
        d:AxHost.AboutBoxDelegate -> unit

The SetAboutBoxDelegate method also allows derived classes to handle the ShowAboutBox method without attaching a delegate. This is the preferred technique for handling the ShowAboutBox method in a derived class.

Notes to Inheritors

When overriding SetAboutBoxDelegate in a derived class, be sure to call the base class's SetAboutBoxDelegate method so that registered delegates receive the ShowAboutBox method.

The following code example overrides the constructor, and the SetAboutBoxDelegate and AttachInterfaces methods of an AxHost derived class that wraps the Microsoft Masked Edit ActiveX Control. This code requires that you have created the generated source code by running the AxImp.exe on the MSMask32.ocx file with the /source switch to generate the wrapper class to be edited. This code is only shown in C# syntax because that is the only language output by the AxImp.exe.

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);
    }
}

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.