public static SafeGDIHandle CreateDib(Rectangle bounds, IntPtr primaryHdc, SafeDeviceHandle memoryHdc)
        {
            BITMAPINFO info = new BITMAPINFO();

            info.biSize        = Marshal.SizeOf(info);
            info.biWidth       = bounds.Width;
            info.biHeight      = -bounds.Height;
            info.biPlanes      = 1;
            info.biBitCount    = 32;
            info.biCompression = 0; // BI_RGB
            SafeGDIHandle dib = CreateDIBSection(primaryHdc, info, 0, IntPtr.Zero, IntPtr.Zero, 0);

            SelectObject(memoryHdc, dib);
            return(dib);
        }
 public static extern void GetThemeTextExtent(IntPtr hTheme, SafeDeviceHandle hdc, int iPartId, int iStateId,
                                              string text, int iCharCount, int dwTextFlags, [In] ref RECT bounds,
                                              out RECT rect);
 public static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight,
                                  SafeDeviceHandle hdcSrc, int nXSrc, int nYSrc, uint dwRop);
 public static extern void DrawThemeTextEx(IntPtr hTheme, SafeDeviceHandle hdc, int iPartId, int iStateId,
                                           string text, int iCharCount, int dwFlags, ref RECT pRect,
                                           ref DTTOPTS pOptions);
 public static extern IntPtr SelectObject(SafeDeviceHandle hDC, SafeGDIHandle hObject);