Ejemplo n.º 1
0
 public static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO pbmi, uint iUsage, int ppvBits, IntPtr hSection, uint dwOffset);
        private static void DrawWrapper(VisualStyleRenderer rnd, IDeviceContext dc, Rectangle bounds, DrawWrapperMethod func)
        {
            using (SafeGDIHandle primaryHdc = new SafeGDIHandle(dc))
            {
                // Create a memory DC so we can work offscreen
                using (SafeCompatibleDCHandle memoryHdc = new SafeCompatibleDCHandle(primaryHdc))
                {
                    // Create a device-independent bitmap and select it into our DC
                    BITMAPINFO info = new BITMAPINFO(bounds.Width, -bounds.Height);
                    using (SafeDCObjectHandle dib = new SafeDCObjectHandle(memoryHdc, GDI.CreateDIBSection(primaryHdc, ref info, 0, 0, IntPtr.Zero, 0)))
                    {
                        // Call method
                        func(memoryHdc);

                        // Copy to foreground
                        const int SRCCOPY = 0x00CC0020;
                        GDI.BitBlt(primaryHdc, bounds.Left, bounds.Top, bounds.Width, bounds.Height, memoryHdc, 0, 0, SRCCOPY);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO pbmi, uint iUsage, int ppvBits, IntPtr hSection, uint dwOffset);