private Size SetExtent(int width, int height) { System.Windows.Forms.NativeMethods.tagSIZEL sz = new System.Windows.Forms.NativeMethods.tagSIZEL { cx = width, cy = height }; bool flag = !this.IsUserMode(); try { this.Pixel2hiMetric(sz, sz); this.GetOleObject().SetExtent(1, sz); } catch (COMException) { flag = true; } if (flag) { this.GetOleObject().GetExtent(1, sz); try { this.GetOleObject().SetExtent(1, sz); } catch (COMException) { } } return this.GetExtent(); }
private Size GetExtent() { System.Windows.Forms.NativeMethods.tagSIZEL pSizel = new System.Windows.Forms.NativeMethods.tagSIZEL(); this.GetOleObject().GetExtent(1, pSizel); this.HiMetric2Pixel(pSizel, pSizel); return new Size(pSizel.cx, pSizel.cy); }