For me it is almost nostalgic to subclass AxHost
for Windows Forms. But this need seemed necessary for a VSTO project of mine. So this was my move:
using System.Drawing;
using System.Windows.Forms;
using stdole;
namespace Songhay.Office2010.WordWalkingStick
{
/// <summary>
/// Exposes selected static members
/// of <see cref="System.Windows.Forms.AxHost"/>.
/// </summary>
/// <remarks>
/// Reference: “The Office Developer Resources Ribbon UI Add-in”
/// http://blogs.msdn.com/b/frice/archive/2009/07/16/the-office-developer-resources-ribbon-ui-add-in.aspx
/// </remarks>
public class WindowsFormsActiveXHost : AxHost
{
/// <summary>
/// Gets the COM <see cref="stdole.IPictureDisp"/>
/// from a managed <see cref="System.Windows.Drawing.Bitmap"/>.
/// </summary>
/// <param name="image">The image.</param>
public static IPictureDisp GetIPictureDisp(Bitmap image)
{
return (IPictureDisp)AxHost.GetIPictureDispFromPicture(image);
}
WindowsFormsActiveXHost(): base(string.Empty) {}
}
}
My intent is to have a general-purpose one-stop shop for all of my ActiveX Host needs. So far, only one method GetIPictureDisp()
. Does anyone else out there need more for general purpose?
(I actually don't need this class at all because the 2010 Ribbon reads Image
types directly.)