private void OnWndProc(WindowMessageEventArgs args)
        {
            if (args.PreventsDefault)
            {
                return;
            }
            switch (args.uMsg)
            {
            case WindowMessageEnum.KEYDOWN: {
                OnKeyDown((Key)args.wParam);
                args.ReturnValue = (IntPtr)1;
                args.PreventDefault();
                break;
            }

            case WindowMessageEnum.KEYUP: {
                OnKeyUp((Key)args.wParam);
                args.ReturnValue = (IntPtr)1;
                args.PreventDefault();
                break;
            }

            case WindowMessageEnum.CHAR: {
                OnKeyPress((Key)args.lParam, (char)args.wParam);
                args.ReturnValue = (IntPtr)1;
                args.PreventDefault();
                break;
            }
            }
        }
        private void OnWndProc(WindowMessageEventArgs args)
        {
            if (args.PreventsDefault)
            {
                return;
            }
            switch (args.uMsg)
            {
            case WindowMessageEnum.LBUTTONDOWN: {
                OnMouseDown((int)MouseButton.Left);
                args.ReturnValue = (IntPtr)1;
                args.PreventDefault();
                break;
            }

            case WindowMessageEnum.LBUTTONUP: {
                OnMouseUp((int)MouseButton.Left);
                args.ReturnValue = (IntPtr)1;
                args.PreventDefault();
                break;
            }

            case WindowMessageEnum.RBUTTONDOWN: {
                OnMouseDown((int)MouseButton.Right);
                args.ReturnValue = (IntPtr)1;
                args.PreventDefault();
                break;
            }

            case WindowMessageEnum.RBUTTONUP: {
                OnMouseUp((int)MouseButton.Right);
                args.ReturnValue = (IntPtr)1;
                args.PreventDefault();
                break;
            }

            case WindowMessageEnum.MBUTTONDOWN: {
                OnMouseDown((int)MouseButton.Middle);
                args.ReturnValue = (IntPtr)1;
                args.PreventDefault();
                break;
            }

            case WindowMessageEnum.MBUTTONUP: {
                OnMouseUp((int)MouseButton.Middle);
                args.ReturnValue = (IntPtr)1;
                args.PreventDefault();
                break;
            }

            case WindowMessageEnum.MOUSEWHEEL: {
                OnMouseWheel(unchecked ((short)(((uint)args.wParam & 0xFFFF0000) >> 16) / 120));
                args.ReturnValue = (IntPtr)1;
                args.PreventDefault();
                break;
            }
            }
        }
 /// <summary>
 /// Override this method if you need to process messages that were not processed by the WndProc() method.
 /// </summary>
 /// <param name="uMsg"></param>
 /// <param name="wParam"></param>
 /// <param name="lParam"></param>
 /// <returns></returns>
 protected virtual IntPtr DefWindowProc(WindowMessageEnum uMsg, IntPtr wParam, IntPtr lParam)
 {
     if (PostprocessWindowMessageEvent != null)
     {
         WindowMessageEventArgs args = new WindowMessageEventArgs(this, uMsg, wParam, lParam);
         PostprocessWindowMessageEvent.Invoke(args);
         if (args.PreventsDefault)
         {
             return(args.ReturnValue);
         }
     }
     return(API.Externals.DefWindowProc(m_hWnd, uMsg, wParam, lParam));
 }
 internal IntPtr WndProcInternal(WindowMessageEnum uMsg, IntPtr wParam, IntPtr lParam)
 {
     if (PreprocessWindowMessageEvent != null)
     {
         WindowMessageEventArgs args = new WindowMessageEventArgs(this, uMsg, wParam, lParam);
         PreprocessWindowMessageEvent.Invoke(args);
         if (args.PreventsDefault)
         {
             return(args.ReturnValue);
         }
     }
     return(WndProc(uMsg, wParam, lParam));
 }
Esempio n. 5
0
        public static IntPtr WndProc(IntPtr hWnd, WindowMessageEnum uMsg, IntPtr wParam, IntPtr lParam)
        {
            Win32NativeWindow window;

            switch (uMsg)
            {
            case WindowMessageEnum.ACTIVATEAPP: {
                Instance.OnActivate(!((int)wParam == 0));
                break;
            }
            }

            if (Instance.Windows.TryGetValue((int)hWnd, out window))
            {
                if (ProcessWindowMessageEvent != null)
                {
                    WindowMessageEventArgs args = new WindowMessageEventArgs(window, uMsg, wParam, lParam);
                    ProcessWindowMessageEvent(args);
                    if (args.PreventsDefault)
                    {
                        return(args.ReturnValue);
                    }
                }
                return(window.WndProcInternal(uMsg, wParam, lParam));
            }

            if (ProcessWindowMessageEvent != null)
            {
                WindowMessageEventArgs args = new WindowMessageEventArgs(hWnd, uMsg, wParam, lParam);
                ProcessWindowMessageEvent(args);
                if (args.PreventsDefault)
                {
                    return(args.ReturnValue);
                }
            }
            return(API.Externals.DefWindowProc(hWnd, uMsg, wParam, lParam));
        }