예제 #1
0
        bool OnWM_MESSAGE256(ref System.Windows.Interop.MSG msg, ref bool handled)
        {
            // // add extra variables to observe with Debugger //
            IntPtr HWND, WParam, LParam;

            HWND                  = msg.hwnd;
            WParam                = msg.wParam;
            LParam                = msg.lParam;
            this.txt_HWND.Text    = HWND.ToString();
            this.txt_WParam.Text  = WParam.ToString();
            this.txt_LParam.Text  = LParam.ToString();
            this.txt_KeyData.Text = KeyInterop.KeyFromVirtualKey(WParam.ToInt32()).ToString();//keyData.ToString();

            return(true);
        }
예제 #2
0
        public static void ReleaseDCChecked(HWND hWnd, HDC hDC)
        {
            int res = ReleaseDC(hWnd, hDC);

            if (res != 1)
            {
                throw new InvalidOperationException($"{nameof(ReleaseDC)} failed. Window handle: 0x{hWnd.ToString("X16")}. HDC: 0x{hDC.ToString("X16")}.");
            }
        }
예제 #3
0
        public static HDC GetDCChecked(HWND hWnd)
        {
            HDC hdc = GetDC(hWnd);

            if (hdc == IntPtr.Zero)
            {
                throw new InvalidOperationException($"{nameof(GetDC)} failed. Window handle: 0x{hWnd.ToString("X16")}.");
            }

            return(hdc);
        }