private Size SetExtent(int width, int height)
        {
            NativeMethods.tagSIZEL size = new NativeMethods.tagSIZEL();
            size.cx = width;
            size.cy = height;
            bool shouldSetExtend = base.DesignMode;

            try
            {
                this.Pixel2hiMetric(size, size);
                this.activeXOleObject.SetExtent(NativeMethods.tagDVASPECT.DVASPECT_CONTENT, size);
            }
            catch (COMException)
            {
                shouldSetExtend = true;
            }
            if (shouldSetExtend)
            {
                this.activeXOleObject.GetExtent(NativeMethods.tagDVASPECT2.DVASPECT_CONTENT, size);
                try
                {
                    this.activeXOleObject.SetExtent(NativeMethods.tagDVASPECT.DVASPECT_CONTENT, size);
                }
                catch (COMException)
                {
                }
            }
            return(this.GetExtent());
        }
 private Size GetExtent()
 {
     NativeMethods.tagSIZEL size = new NativeMethods.tagSIZEL();
     this.activeXOleObject.GetExtent(NativeMethods.tagDVASPECT2.DVASPECT_CONTENT, size);
     this.HiMetric2Pixel(size, size);
     return(new Size(size.cx, size.cy));
 }
 private void HiMetric2Pixel(NativeMethods.tagSIZEL sz, NativeMethods.tagSIZEL szout)
 {
     NativeMethods._POINTL _pointl = new NativeMethods._POINTL();
     _pointl.x = sz.cx;
     _pointl.y = sz.cy;
     NativeMethods.tagPOINTF pointf = new NativeMethods.tagPOINTF();
     ((UnsafeNativeMethods.IOleControlSite) this.activeXSite).TransformCoords(_pointl, pointf, NativeMethods.tagXFORMCOORDS.XFORMCOORDS_HIMETRICTOCONTAINER | NativeMethods.tagXFORMCOORDS.XFORMCOORDS_SIZE);
     szout.cx = (int)pointf.x;
     szout.cy = (int)pointf.y;
 }