コード例 #1
0
 private static extern bool _UpdateLayeredWindow(
     IntPtr hwnd,
     SafeDC hdcDst,
     [In] ref POINT pptDst,
     [In] ref SIZE psize,
     SafeDC hdcSrc,
     [In] ref POINT pptSrc,
     int crKey,
     ref BLENDFUNCTION pblend,
     ULW dwFlags);
コード例 #2
0
        public static SafeDC CreateCompatibleDC(SafeDC hdc)
        {
            SafeDC dc = null;
            try
            {
                IntPtr hPtr = IntPtr.Zero;
                if (hdc != null)
                {
                    hPtr = hdc.handle;
                }
                dc = NativeMethods.CreateCompatibleDC(hPtr);
                if (dc == null)
                {
                    HRESULT.ThrowLastError();
                }
            }
            finally
            {
                if (dc != null)
                {
                    dc._created = true;
                }
            }

            if (dc.IsInvalid)
            {
                dc.Dispose();
                throw new SystemException("Unable to create a device context from the specified device information.");
            }

            return dc;
        }
コード例 #3
0
 private static extern IntPtr _SelectObject(SafeDC hdc, IntPtr hgdiobj);
コード例 #4
0
 private static extern IntPtr _SelectObjectSafeHBITMAP(SafeDC hdc, SafeHBITMAP hgdiobj);
コード例 #5
0
 private static extern SafeHBITMAP _CreateDIBSection(SafeDC hdc, [In] ref BITMAPINFO bitmapInfo, int iUsage, [Out] out IntPtr ppvBits, IntPtr hSection, int dwOffset);
コード例 #6
0
 public static void UpdateLayeredWindow(
     IntPtr hwnd,
     SafeDC hdcDst,
     ref POINT pptDst,
     ref SIZE psize,
     SafeDC hdcSrc,
     ref POINT pptSrc,
     int crKey,
     ref BLENDFUNCTION pblend,
     ULW dwFlags)
 {
     if (!_UpdateLayeredWindow(hwnd, hdcDst, ref pptDst, ref psize, hdcSrc, ref pptSrc, crKey, ref pblend, dwFlags))
     {
         HRESULT.ThrowLastError();
     }
 }
コード例 #7
0
 public static IntPtr SelectObject(SafeDC hdc, SafeHBITMAP hgdiobj)
 {
     IntPtr ret = _SelectObjectSafeHBITMAP(hdc, hgdiobj);
     if (ret == IntPtr.Zero)
     {
         HRESULT.ThrowLastError();
     }
     return ret;
 }
コード例 #8
0
 public static extern int GetDeviceCaps(SafeDC hdc, DeviceCap nIndex);
コード例 #9
0
        public static SafeHBITMAP CreateDIBSection(SafeDC hdc, ref BITMAPINFO bitmapInfo, out IntPtr ppvBits, IntPtr hSection, int dwOffset)
        {
            const int DIB_RGB_COLORS = 0;
            SafeHBITMAP hBitmap = null;
            if (hdc == null)
            {
                hBitmap = _CreateDIBSectionIntPtr(IntPtr.Zero, ref bitmapInfo, DIB_RGB_COLORS, out ppvBits, hSection, dwOffset);
            }
            else
            {
                hBitmap = _CreateDIBSection(hdc, ref bitmapInfo, DIB_RGB_COLORS, out ppvBits, hSection, dwOffset);
            }

            if (hBitmap.IsInvalid)
            {
                HRESULT.ThrowLastError();
            }

            return hBitmap;
        }