示例#1
0
        void Form_Activated(object sender, EventArgs e)
        {
            //  通知 MessageFilter 鼠标已离开 , 参考上面 OnMouseEnterEx() 方法里的注释
            MouseEventUtil.SetLeave(this);

            OnMouseLeaveEx(e);
        }
示例#2
0
        private bool RaiseCommonEvent(ref Message m, Control c)
        {
            FormEx    form = c as FormEx;
            ControlEx ctrl = c as ControlEx;

            if (form == null && ctrl == null)
            {
                return(false);
            }


            EventArgs e;

            bool r = false;

            switch (m.Msg)
            {
            case Win32.WM_MOUSEHOVER:
            {
                e = new EventArgs();

                if (form != null)
                {
                    r = form.OnMouseHoverEx(e);
                }
                else if (ctrl != null)
                {
                    r = ctrl.OnMouseHoverEx(e);
                }

                // 如果 r == true , 则返回 true 终止事件冒泡
                if (r)
                {
                    return(true);
                }

                break;
            }

            case Win32.WM_MOUSELEAVE:
            {
                //  用于实现 MouseEnter 事件, 参考 MouseMove 消息处理中使用  MouseEventUtil.SetEnter(c) 的部分
                MouseEventUtil.SetLeave(c);

                e = new EventArgs();

                if (form != null)
                {
                    r = form.OnMouseLeaveEx(e);
                }
                else if (ctrl != null)
                {
                    r = ctrl.OnMouseLeaveEx(e);
                }

                // 如果 r == true , 则返回 true 终止事件冒泡
                if (r)
                {
                    return(true);
                }

                break;
            }
            }

            return(false);
        }