コード例 #1
0
ファイル: PrintCaptureHelper.cs プロジェクト: vantk85/openrpa
        public void Cleanup()
        {
            if (_hBitmap.Equals(IntPtr.Zero))
            {
                return;
            }

            Win32Funcs.SelectObject(_hMemDc, _hOldBitmap);
            Win32Funcs.DeleteObject(_hBitmap);
            Win32Funcs.DeleteDC(_hMemDc);
            Win32Funcs.ReleaseDC(_hWnd, _hScrDc);

            _hWnd       = IntPtr.Zero;
            _hScrDc     = IntPtr.Zero;
            _hMemDc     = IntPtr.Zero;
            _hBitmap    = IntPtr.Zero;
            _hOldBitmap = IntPtr.Zero;
        }
コード例 #2
0
ファイル: PrintCaptureHelper.cs プロジェクト: vantk85/openrpa
        public bool Init(IntPtr handle)
        {
            _hWnd = handle;

            if (!Win32Funcs.GetWindowRect(_hWnd, out _windowRect) ||
                !Win32Funcs.GetClientRect(_hWnd, out _clientRect))
            {
                return(false);
            }

            _bmpDataSize = _windowRect.Width * _windowRect.Height * 3;

            _hScrDc     = Win32Funcs.GetWindowDC(_hWnd);
            _hBitmap    = Win32Funcs.CreateCompatibleBitmap(_hScrDc, _windowRect.Width, _windowRect.Height);
            _hMemDc     = Win32Funcs.CreateCompatibleDC(_hScrDc);
            _hOldBitmap = Win32Funcs.SelectObject(_hMemDc, _hBitmap);

            return(true);
        }