Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
190
Cannot disable mouse wheel in UltraComboEditor.
posted

I want to disable mouse wheel in UltraComboEditor. In other words, I don't want user to select the item by mouse wheel, they can just select item from drop down list. I've tried many ways and all failed. But MS comboBox can handle everything as I want.

Then I made an experiment between MS comboBox and UltraComboEditor. I find that UltraComboEditor can not handle mouse wheel event while MS comboBox can.  I tried 3 ways to debug whether this control can capture mouse wheel event. Blow is the 3 ways of my experiment. I set several breakponts to ensure combobox can handle mouse wheel event. MS combo can enter all the breakponts but UltraCombo can't. Anyone can help me? 

        const int WM_MOUSEWHEEL = 0x020A;

        protected override void WndProc(ref Message m)
        {
            //stop scroll
            if (m.Msg == WM_MOUSEWHEEL)
            {
                //but force next item
                int delta;
                if ((int)m.WParam > 0)
                {
                    //up
                    delta = 1;
                }
                else
                {
                    //down
                    delta = -1;
                }
                this.OnMouseWheel(new MouseEventArgs(MouseButtons.None, 0, 0, 0, delta));

                return;
            }

            base.WndProc(ref m);
        }

        protected override void OnMouseWheel(MouseEventArgs e)
        {
            base.OnMouseWheel(e);
        }

       public Form1()
        {
            this.testUltraCmb1.MouseWheel += new MouseEventHandler(testUltraCmb1_MouseWheel);
        }

        public void testUltraCmb1_MouseWheel(object sender, MouseEventArgs e)
        {
            HandledMouseEventArgs handledArgs = e as HandledMouseEventArgs;
            if (handledArgs != null)
                handledArgs.Handled = true;
        }