Exemple #1
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == NativeMethods.WM_LBUTTONUP || m.Msg == NativeMethods.WM_LBUTTONDOWN)
            {
                var info = new NativeMethods.LVHITTESTINFO();

                info.pt = NativeMethods.LParamToPOINT((uint)m.LParam);

                //if the click is on the group header, exit, otherwise send message
                var handleRef = new HandleRef(this, Handle);
                if (NativeMethods.SendMessage(handleRef, NativeMethods.LVM_SUBITEMHITTEST, (IntPtr)(-1), ref info) != -1)
                    if ((info.flags & NativeMethods.LVHITTESTFLAGS.LVHT_EX_GROUP_HEADER) != 0)
                        return;
            }
            base.WndProc(ref m);
        }
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case NativeMethods.WM_PAINT:
                    _isInWmPaintMsg = true;
                    base.WndProc(ref m);
                    _isInWmPaintMsg = false;
                    break;
                case NativeMethods.WM_REFLECT_NOTIFY:
                    var nmhdr = (NativeMethods.NMHDR)m.GetLParam(typeof(NativeMethods.NMHDR));
                    if (nmhdr.code == -12)
                    {
                        // NM_CUSTOMDRAW
                        if (_isInWmPaintMsg)
                            base.WndProc(ref m);
                    }
                    else
                        base.WndProc(ref m);
                    break;
                case NativeMethods.WM_LBUTTONUP:
                case NativeMethods.WM_LBUTTONDOWN:
                    var info = new NativeMethods.LVHITTESTINFO();

                    info.pt = NativeMethods.LParamToPOINT((uint)m.LParam);

                    //if the click is on the group header, exit, otherwise send message
                    var handleRef = new HandleRef(this, Handle);
                    if (NativeMethods.SendMessage(handleRef, NativeMethods.LVM_SUBITEMHITTEST, (IntPtr)(-1), ref info) != -1)
                        if ((info.flags & NativeMethods.LVHITTESTFLAGS.LVHT_EX_GROUP_HEADER) != 0)
                            return;
                    base.WndProc(ref m);
                    break;
                default:
                    base.WndProc(ref m);
                    break;
            }
        }