ComponentFactory.Krypton.Toolkit.KryptonCheckedListBox.InternalCheckedListBox.WndProc C# (CSharp) Method

WndProc() protected method

Process Windows-based messages.
protected WndProc ( Message &m ) : void
m System.Windows.Forms.Message A Windows-based message.
return void
            protected override void WndProc(ref Message m)
            {
                if (m.Msg == LBC_GETCHECKSTATE)
                {
                    int wParam = (int)m.WParam.ToInt64();
                    if ((wParam < 0) || (wParam >= Items.Count))
                        m.Result = (IntPtr)(-1);
                    else
                        m.Result = _kryptonCheckedListBox.GetItemChecked(wParam) ? ((IntPtr)1) : IntPtr.Zero;
                }
                else if (m.Msg == LBC_SETCHECKSTATE)
                {
                    int index = (int)m.WParam.ToInt64();
                    int lParam = (int)m.LParam;
                    if (((index < 0) || (index >= this.Items.Count)) || ((lParam != 1) && (lParam != 0)))
                        m.Result = IntPtr.Zero;
                    else
                    {
                        _kryptonCheckedListBox.SetItemChecked(index, lParam == 1);
                        m.Result = (IntPtr)1;
                    }
                }

                switch (m.Msg)
                {
                    case PI.WM_KEYDOWN:
                        WmKeyDown(ref m);
                        base.WndProc(ref m);
                        return;
                    case PI.WM_ERASEBKGND:
                        // Do not draw the background here, always do it in the paint
                        // instead to prevent flicker because of a two stage drawing process
                        break;
                    case PI.WM_PRINTCLIENT:
                    case PI.WM_PAINT:
                        WmPaint(ref m);
                        break;
                    case PI.WM_VSCROLL:
                    case PI.WM_HSCROLL:
                    case PI.WM_MOUSEWHEEL:
                        Invalidate();
                        base.WndProc(ref m);
                        break;
                    case PI.WM_MOUSELEAVE:
                        // Mouse is not over the control
                        MouseOver = false;
                        _kryptonCheckedListBox.PerformNeedPaint(true);
                        Invalidate();
                        base.WndProc(ref m);
                        break;
                    case PI.WM_MOUSEMOVE:
                        // Mouse is over the control
                        if (!MouseOver)
                        {
                            MouseOver = true;
                            _kryptonCheckedListBox.PerformNeedPaint(true);
                            Invalidate();
                        }
                        else
                        {
                            // Find the item under the mouse
                            Point mousePoint = new Point((int)m.LParam.ToInt64());
                            int mouseIndex = IndexFromPoint(mousePoint);

                            // If we have an actual item from the point
                            if ((mouseIndex >= 0) && (mouseIndex < Items.Count))
                            {
                                // Check that the mouse really is in the item rectangle
                                Rectangle indexRect = GetItemRectangle(mouseIndex);
                                if (!indexRect.Contains(mousePoint))
                                    mouseIndex = -1;
                            }

                            // If item under mouse has changed, then need to reflect for tracking
                            if (_mouseIndex != mouseIndex)
                            {
                                Invalidate();
                                _mouseIndex = mouseIndex;
                            }
                        }
                        base.WndProc(ref m);
                        break;
                    default:
                        base.WndProc(ref m);
                        break;
                }
            }