void SetupWindowCapture()
        {
            //UpdateCursorInfo();

            // Get the device context
            if (isDesktop)
            {
                hdc = Win32Funcs.GetDC(IntPtr.Zero);
            }
            else
            {
                hdc = Win32Funcs.GetWindowDC(hwnd);
            }

            // Create a device context to use yourself
            hDest = Win32Funcs.CreateCompatibleDC(hdc);

            Win32Types.RECT windowRect;

            if (isDesktop)
            {
                Win32Types.MonitorInfo mi = new Win32Types.MonitorInfo();
                mi.cbSize = Marshal.SizeOf(mi);
                Win32Funcs.GetMonitorInfo(hwnd, ref mi);
                windowRect = mi.rcMonitor;
            }
            else
            {
                // Get the size of the window
                Win32Funcs.GetWindowRect(hwnd, out windowRect);
            }
            // Sets the width and height of the captured window
            windowWidth  = windowRect.Width;
            windowHeight = windowRect.Height;

            if (onlyCaptureMouse)
            {
                windowWidth  = cursorRect.Width;
                windowHeight = cursorRect.Height;
            }

            // From http://stackoverflow.com/questions/7502588/createcompatiblebitmap-and-createdibsection-memory-dcs
            bmi = new Win32Types.BitmapInfo();
            bmi.bmiHeader.Init();
            bmi.bmiHeader.biSize        = (uint)Marshal.SizeOf(bmi);
            bmi.bmiHeader.biWidth       = windowWidth;
            bmi.bmiHeader.biHeight      = -windowHeight; // top-down
            bmi.bmiHeader.biPlanes      = 1;
            bmi.bmiHeader.biBitCount    = 24;
            bmi.bmiHeader.biCompression = Win32Consts.BitmapCompressionMode.BI_RGB;


            IntPtr outBits;

            curRenderingBitmap = Win32Funcs.CreateDIBSection(hdc, ref bmi, (uint)Win32Consts.DIB_Color_Mode.DIB_PAL_COLORS, out outBits, IntPtr.Zero, (uint)0);

            oldhDest = Win32Funcs.SelectObject(hDest, curRenderingBitmap);
        }