private System.Drawing.Size GetIconSize(IntPtr iconHandle)
 {
     System.Drawing.Size size = this.Size;
     System.Windows.Forms.NativeMethods.ICONINFO info = new System.Windows.Forms.NativeMethods.ICONINFO();
     System.Windows.Forms.SafeNativeMethods.GetIconInfo(new HandleRef(this, iconHandle), info);
     System.Windows.Forms.NativeMethods.BITMAP bm = new System.Windows.Forms.NativeMethods.BITMAP();
     if (info.hbmColor != IntPtr.Zero)
     {
         System.Windows.Forms.UnsafeNativeMethods.GetObject(new HandleRef(null, info.hbmColor), Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.BITMAP)), bm);
         System.Windows.Forms.SafeNativeMethods.IntDeleteObject(new HandleRef(null, info.hbmColor));
         size = new System.Drawing.Size(bm.bmWidth, bm.bmHeight);
     }
     else if (info.hbmMask != IntPtr.Zero)
     {
         System.Windows.Forms.UnsafeNativeMethods.GetObject(new HandleRef(null, info.hbmMask), Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.BITMAP)), bm);
         size = new System.Drawing.Size(bm.bmWidth, bm.bmHeight / 2);
     }
     if (info.hbmMask != IntPtr.Zero)
     {
         System.Windows.Forms.SafeNativeMethods.IntDeleteObject(new HandleRef(null, info.hbmMask));
     }
     return(size);
 }
 private System.Drawing.Size GetIconSize(IntPtr iconHandle)
 {
     System.Drawing.Size size = this.Size;
     System.Windows.Forms.NativeMethods.ICONINFO info = new System.Windows.Forms.NativeMethods.ICONINFO();
     System.Windows.Forms.SafeNativeMethods.GetIconInfo(new HandleRef(this, iconHandle), info);
     System.Windows.Forms.NativeMethods.BITMAP bm = new System.Windows.Forms.NativeMethods.BITMAP();
     if (info.hbmColor != IntPtr.Zero)
     {
         System.Windows.Forms.UnsafeNativeMethods.GetObject(new HandleRef(null, info.hbmColor), Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.BITMAP)), bm);
         System.Windows.Forms.SafeNativeMethods.IntDeleteObject(new HandleRef(null, info.hbmColor));
         size = new System.Drawing.Size(bm.bmWidth, bm.bmHeight);
     }
     else if (info.hbmMask != IntPtr.Zero)
     {
         System.Windows.Forms.UnsafeNativeMethods.GetObject(new HandleRef(null, info.hbmMask), Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.BITMAP)), bm);
         size = new System.Drawing.Size(bm.bmWidth, bm.bmHeight / 2);
     }
     if (info.hbmMask != IntPtr.Zero)
     {
         System.Windows.Forms.SafeNativeMethods.IntDeleteObject(new HandleRef(null, info.hbmMask));
     }
     return size;
 }