O'Reilly logo

.NET Windows Forms in a Nutshell by Matthew Adams, Ian Griffiths

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

AxHost

Synopsis

This Control class wraps ActiveX controls that have been imported into the managed environment (either by use of the Aximp.exe tool or, more commonly, by adding them to the designer by customizing the toolbox). It extends the base services to provide methods to get the underlying OCX control (GetOcx()) and show property pages (ShowPropertyPages()), if they are present (HasPropertyPages()).

Note that several of the events you would normally expect from a Control are not supported (e.g., color and font property changes), and attempting to bind to them will cause a NotSupportedException. The Liskov substitution principle states that you should be able to use any instance of a derived class in place of an instance of the base class. Throwing that exception means that this class violates that principle. Therefore, you have to take care if you are using Control objects polymorphically in your application (e.g., in your own custom host), in case someone drops an ActiveX control into the equation.


public abstract class AxHost : Control : 

System.ComponentModel.ISupportInitialize, System.ComponentModel.ICustomTypeDescriptor {

// Protected Constructors

   protected AxHost(string clsid);

   protected AxHost(string clsid, int flags);

// Public Instance Properties

   public override Color BackColor{set; get; } // overrides Control

   public override Image BackgroundImage{set; get; } // overrides Control

   public ContainerControl ContainingControl{set; get; }

   public override ContextMenu 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required