Exemple #1
0
 // Catch middle clicks
 private bool BreadcrumbController_MessageCaptured(ref Message msg)
 {
     if (msg.Msg == WM.MBUTTONUP)
     {
         if (hdpa != IntPtr.Zero && ItemClicked != null)
         {
             int idx = HitTest(QTUtility2.PointFromLPARAM(msg.LParam));
             if (idx >= 0 && idx <= ButtonCount())
             {
                 DoItemClick(IndexToCommand(idx), Control.ModifierKeys, true);
             }
         }
     }
     return(false);
 }
Exemple #2
0
        protected virtual bool ListViewController_MessageCaptured(ref Message msg)
        {
            if (msg.Msg == WM_AFTERPAINT)
            {
                RefreshSubDirTip(true);
                return(true);
            }
            else if (msg.Msg == WM_REGISTERDRAGDROP)
            {
                IntPtr ptr = Marshal.ReadIntPtr(msg.WParam);
                if (dropTargetPassthrough != null)
                {
                    // If this is the RegisterDragDrop call from the constructor,
                    // don't mess it up!
                    if (dropTargetPassthrough.Pointer == ptr)
                    {
                        return(true);
                    }
                    dropTargetPassthrough.Dispose();
                }
                dropTargetPassthrough = TryMakeDTPassthrough(ptr);
                if (dropTargetPassthrough != null)
                {
                    Marshal.WriteIntPtr(msg.WParam, dropTargetPassthrough.Pointer);
                }
                return(true);
            }

            switch (msg.Msg)
            {
            case WM.DESTROY:
                HideThumbnailTooltip(7);
                HideSubDirTip(7);
                ListViewController.DefWndProc(ref msg);
                OnListViewDestroyed();
                return(true);

            case WM.PAINT:
                // It's very dangerous to do automation-related things
                // during WM_PAINT.  So, use PostMessage to do it later.
                PInvoke.PostMessage(ListViewController.Handle, WM_AFTERPAINT, IntPtr.Zero, IntPtr.Zero);
                break;

            case WM.MOUSEMOVE:
                ResetTrackMouseEvent();
                break;

            case WM.LBUTTONDBLCLK:
                if (DoubleClick != null)
                {
                    return(DoubleClick(QTUtility2.PointFromLPARAM(msg.LParam)));
                }
                break;

            case WM.MBUTTONUP:
                if (MiddleClick != null)
                {
                    MiddleClick(QTUtility2.PointFromLPARAM(msg.LParam));
                }
                break;

            case WM.MOUSEWHEEL: {
                IntPtr handle = PInvoke.WindowFromPoint(QTUtility2.PointFromLPARAM(msg.LParam));
                if (handle != IntPtr.Zero && handle != msg.HWnd)
                {
                    Control control = Control.FromHandle(handle);
                    if (control != null)
                    {
                        DropDownMenuReorderable reorderable = control as DropDownMenuReorderable;
                        if ((reorderable != null) && reorderable.CanScroll)
                        {
                            PInvoke.SendMessage(handle, WM.MOUSEWHEEL, msg.WParam, msg.LParam);
                        }
                    }
                }
                break;
            }

            case WM.MOUSELEAVE:
                fTrackMouseEvent = true;
                HideThumbnailTooltip(4);
                if (((subDirTip != null) && !subDirTip.MouseIsOnThis()) && !subDirTip.MenuIsShowing)
                {
                    HideSubDirTip(5);
                }
                break;
            }
            return(false);
        }
Exemple #3
0
 public override int HitTest(IntPtr LParam)
 {
     return(HitTest(QTUtility2.PointFromLPARAM(LParam), false));
 }
        protected override void WndProc(ref Message m)
        {
            try {
                QMenuItem ownerItem;
                if (!fRespondModKeys)
                {
                    base.WndProc(ref m);
                    return;
                }
                int wParam = (int)((long)m.WParam);
                switch (m.Msg)
                {
                case WM.KEYDOWN:
                    break;

                case WM.KEYUP:
                    if (fOnceKeyDown && ((wParam == 0x10) || (wParam == 0x11)))
                    {
                        bool flag2 = false;
                        foreach (QMenuItem item4 in lstQMIResponds.Where(item4 => item4.Selected))
                        {
                            if (item4.Enabled)
                            {
                                Keys modifierKeys = ModifierKeys;
                                if (modifierKeys == Keys.Control)
                                {
                                    item4.ImageKey = "control";
                                }
                                else if (fEnableShiftKey && (modifierKeys == Keys.Shift))
                                {
                                    item4.ImageKey = "shift";
                                }
                                else
                                {
                                    item4.RestoreOriginalImage(fChangeImageSelected, false);
                                }
                                lastKeyImageChangedItem = item4;
                            }
                            flag2 = true;
                            break;
                        }
                        ownerItem = OwnerItem as QMenuItem;
                        if (ownerItem != null)
                        {
                            DropDownMenuBase owner = ownerItem.Owner as DropDownMenuBase;
                            if ((owner != null) && owner.Visible)
                            {
                                if (flag2)
                                {
                                    PInvoke.SendMessage(owner.Handle, 0x2a3, IntPtr.Zero, IntPtr.Zero);
                                }
                                else
                                {
                                    QTUtility2.SendCOPYDATASTRUCT(owner.Handle, (IntPtr)wParam, string.Empty, (IntPtr)1);
                                }
                            }
                        }
                    }
                    goto Label_07C2;

                case WM.MOUSEMOVE:
                    goto Label_0562;

                case WM.MOUSELEAVE:
                    goto Label_072E;

                case WM.PAINT:
                    if (fSuspendPainting)
                    {
                        PInvoke.ValidateRect(m.HWnd, IntPtr.Zero);
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    return;

                case WM.COPYDATA: {
                    COPYDATASTRUCT copydatastruct = (COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
                    ownerItem = GetItemAt(PointToClient(MousePosition)) as QMenuItem;
                    if (!(copydatastruct.dwData == IntPtr.Zero))
                    {
                        goto Label_04B6;
                    }
                    if (ownerItem == null)
                    {
                        goto Label_0462;
                    }
                    Keys keys3 = ModifierKeys;
                    if ((wParam == 0x11) && ((keys3 & Keys.Shift) != Keys.Shift))
                    {
                        ownerItem.ImageKey = "control";
                    }
                    else if ((fEnableShiftKey && (wParam == 0x10)) && ((keys3 & Keys.Control) != Keys.Control))
                    {
                        ownerItem.ImageKey = "shift";
                    }
                    else
                    {
                        ownerItem.RestoreOriginalImage(fChangeImageSelected, false);
                    }
                    lastKeyImageChangedItem = ownerItem;
                    goto Label_07C2;
                }

                default:
                    goto Label_07C2;
                }
                fOnceKeyDown = true;
                if ((((int)((long)m.LParam)) & 0x40000000) == 0)
                {
                    if ((wParam == 0x10) || (wParam == 0x11))
                    {
                        bool flag = false;
                        foreach (QMenuItem item2 in lstQMIResponds.Where(item2 => item2.Selected))
                        {
                            if (item2.Enabled)
                            {
                                Keys keys = ModifierKeys;
                                if ((wParam == 0x11) && ((keys & Keys.Shift) != Keys.Shift))
                                {
                                    item2.ImageKey = "control";
                                }
                                else if ((fEnableShiftKey && (wParam == 0x10)) && ((keys & Keys.Control) != Keys.Control))
                                {
                                    item2.ImageKey = "shift";
                                }
                                else
                                {
                                    item2.RestoreOriginalImage(fChangeImageSelected, false);
                                }
                                lastKeyImageChangedItem = item2;
                            }
                            flag = true;
                            break;
                        }
                        ownerItem = OwnerItem as QMenuItem;
                        if (ownerItem != null)
                        {
                            DropDownMenuBase base2 = ownerItem.Owner as DropDownMenuBase;
                            if ((base2 != null) && base2.Visible)
                            {
                                if (flag)
                                {
                                    PInvoke.SendMessage(base2.Handle, 0x2a3, IntPtr.Zero, IntPtr.Zero);
                                }
                                else
                                {
                                    QTUtility2.SendCOPYDATASTRUCT(base2.Handle, (IntPtr)wParam, string.Empty, IntPtr.Zero);
                                }
                            }
                        }
                    }
                    else if ((wParam == 13) && ((fEnableShiftKey && (ModifierKeys == Keys.Shift)) || (ModifierKeys == Keys.Control)))
                    {
                        foreach (ToolStripItem item3 in Items)
                        {
                            if (item3.Selected)
                            {
                                if (item3.Enabled)
                                {
                                    OnItemClicked(new ToolStripItemClickedEventArgs(item3));
                                }
                                break;
                            }
                        }
                    }
                }
                goto Label_07C2;
Label_0462:
                ownerItem = OwnerItem as QMenuItem;
                if (ownerItem != null)
                {
                    DropDownMenuBase base4 = ownerItem.Owner as DropDownMenuBase;
                    if ((base4 != null) && base4.Visible)
                    {
                        QTUtility2.SendCOPYDATASTRUCT(base4.Handle, (IntPtr)wParam, string.Empty, IntPtr.Zero);
                    }
                }
                goto Label_07C2;
Label_04B6:
                if (ownerItem != null)
                {
                    Keys keys4 = ModifierKeys;
                    if (keys4 == Keys.Control)
                    {
                        ownerItem.ImageKey = "control";
                    }
                    else if (fEnableShiftKey && (keys4 == Keys.Shift))
                    {
                        ownerItem.ImageKey = "shift";
                    }
                    else
                    {
                        ownerItem.RestoreOriginalImage(fChangeImageSelected, false);
                    }
                    lastKeyImageChangedItem = ownerItem;
                }
                else
                {
                    ownerItem = OwnerItem as QMenuItem;
                    if (ownerItem != null)
                    {
                        DropDownMenuBase base5 = ownerItem.Owner as DropDownMenuBase;
                        if ((base5 != null) && base5.Visible)
                        {
                            QTUtility2.SendCOPYDATASTRUCT(base5.Handle, (IntPtr)wParam, string.Empty, (IntPtr)1);
                        }
                    }
                }
                goto Label_07C2;
Label_0562:
                if ((m.WParam == IntPtr.Zero) && (m.LParam == lparamPreviousMouseMove))
                {
                    m.Result = IntPtr.Zero;
                    return;
                }
                lparamPreviousMouseMove = m.LParam;
                if ((!fEnableShiftKey || ((wParam & 4) != 4)) && (((wParam & 8) != 8) && !fChangeImageSelected))
                {
                    goto Label_07C2;
                }
                ToolStripItem itemAt = GetItemAt(QTUtility2.PointFromLPARAM(m.LParam));
                if (itemAt == null)
                {
                    base.WndProc(ref m);
                    return;
                }
                ownerItem = itemAt as QMenuItem;
                if (!IsQmiResponds(ownerItem))
                {
                    goto Label_06F8;
                }
                if (ownerItem == lastMouseActiveItem)
                {
                    goto Label_07C2;
                }
                if (lstQMIResponds.Count > 0x1c)
                {
                    fSuspendPainting = true;
                }
                SuspendLayout();
                if (ownerItem.Enabled)
                {
                    switch (wParam)
                    {
                    case 8:
                        ownerItem.ImageKey = "control";
                        goto Label_06AB;

                    case 4:
                        ownerItem.ImageKey = "shift";
                        goto Label_06AB;
                    }
                    if (((ownerItem.Genre == MenuGenre.Navigation) && (ownerItem.MenuItemArguments != null)) && (!ownerItem.MenuItemArguments.IsBack || (ownerItem.MenuItemArguments.Index != 0)))
                    {
                        ownerItem.ImageKey = ownerItem.MenuItemArguments.IsBack ? "back" : "forward";
                    }
                    else
                    {
                        ownerItem.RestoreOriginalImage();
                    }
                }
Label_06AB:
                if (lastMouseActiveItem != null)
                {
                    lastMouseActiveItem.RestoreOriginalImage();
                }
                if ((ownerItem != lastKeyImageChangedItem) && (lastKeyImageChangedItem != null))
                {
                    lastKeyImageChangedItem.RestoreOriginalImage();
                    lastKeyImageChangedItem = null;
                }
                lastMouseActiveItem = ownerItem;
                fSuspendPainting    = false;
                ResumeLayout(false);
                goto Label_07C2;
Label_06F8:
                if (lastMouseActiveItem != null)
                {
                    lastMouseActiveItem.RestoreOriginalImage();
                    lastMouseActiveItem = null;
                }
                if (lastKeyImageChangedItem != null)
                {
                    lastKeyImageChangedItem.RestoreOriginalImage();
                    lastKeyImageChangedItem = null;
                }
                goto Label_07C2;
Label_072E:
                ResetImageKeys();
                lastMouseActiveItem = null;
            }
            catch (Exception exception) {
                QTUtility2.MakeErrorLog(exception, "MSG:" + m.Msg.ToString("X") + ", WPARAM:" + m.WParam.ToString("X") + ", LPARAM:" + m.LParam.ToString("X"));
            }
Label_07C2:
            base.WndProc(ref m);
            fSuspendPainting = false;
        }
        protected override bool ListViewController_MessageCaptured(ref Message msg)
        {
            if (msg.Msg == WM_AFTERPAINT)
            {
                RefreshCache();
            }
            else if (msg.Msg == WM_ISITEMSVIEW)
            {
                msg.Result = (IntPtr)1;
                return(true);
            }

            if (base.ListViewController_MessageCaptured(ref msg))
            {
                return(true);
            }

            switch (msg.Msg)
            {
            case LVM.SCROLL: {
                int amount = msg.WParam.ToInt32();
                SetRedraw(false);
                AutomationManager.DoQuery(factory => {
                        AutomationElement elem = factory.FromHandle(Handle);
                        amount  /= SystemInformation.MouseWheelScrollDelta;
                        bool dec = amount < 0;
                        if (dec)
                        {
                            amount = -amount;
                        }
                        int lines = SystemInformation.MouseWheelScrollLines;
                        if (lines < 0)
                        {
                            elem.ScrollHorizontal(dec
                                    ? ScrollAmount.LargeDecrement
                                    : ScrollAmount.LargeIncrement, amount);
                        }
                        else
                        {
                            elem.ScrollHorizontal(dec
                                    ? ScrollAmount.SmallDecrement
                                    : ScrollAmount.SmallIncrement, amount * lines);
                        }
                        return(0);
                    });
                SetRedraw(true);
                return(true);
            }

            case WM.MOUSEACTIVATE: {
                int  res = (int)msg.Result;
                bool ret = OnMouseActivate(ref res);
                msg.Result = (IntPtr)res;
                return(ret);
            }

            case WM.LBUTTONDOWN: {
                // The ItemsView's window class doesn't have the CS_DBLCLKS
                // class style, which means we won't be receiving the
                // WM.LBUTTONDBLCLK message.  We'll just have to make do
                // without...
                Int64 now = DateTime.Now.Ticks;
                Point pt  = QTUtility2.PointFromLPARAM(msg.LParam);
                if ((now - lastLButtonTime) / 10000 <= SystemInformation.DoubleClickTime)
                {
                    Size size = SystemInformation.DoubleClickSize;
                    if (Math.Abs(pt.X - lastLButtonPoint.X) <= size.Width)
                    {
                        if (Math.Abs(pt.Y - lastLButtonPoint.Y) <= size.Height)
                        {
                            lastLButtonTime = 0;
                            return(OnDoubleClick(pt));
                        }
                    }
                }
                lastLButtonPoint = pt;
                lastLButtonTime  = now;
                return(false);
            }

            case WM.MOUSEMOVE: {
                Point pt = QTUtility2.PointFromLPARAM(msg.LParam);
                if (pt != lastMouseMovePoint)
                {
                    lastMouseMovePoint = pt;
                    if (focusedElement != null)
                    {
                        if (hotElement == null && focusedElement.FullRect.Contains(pt))
                        {
                            PInvoke.PostMessage(Handle, WM_AFTERPAINT, IntPtr.Zero, IntPtr.Zero);
                        }
                        else if (hotElement != null && hotElement.Index == focusedElement.Index && !focusedElement.FullRect.Contains(pt))
                        {
                            PInvoke.PostMessage(Handle, WM_AFTERPAINT, IntPtr.Zero, IntPtr.Zero);
                        }
                    }
                }
                break;
            }

            case WM.MOUSELEAVE:
                if (focusedElement != null)
                {
                    if (hotElement != null && hotElement.Index == focusedElement.Index)
                    {
                        PInvoke.PostMessage(Handle, WM_AFTERPAINT, IntPtr.Zero, IntPtr.Zero);
                    }
                }
                break;

            case WM.KEYDOWN:
                return(OnKeyDown((Keys)msg.WParam));

            case WM.LBUTTONUP:
            case WM.RBUTTONUP:
            case WM.MBUTTONUP:
                RefreshCache();
                break;

            case WM.NOTIFY: {
                NMHDR nmhdr = (NMHDR)Marshal.PtrToStructure(msg.LParam, typeof(NMHDR));
                if (nmhdr.code == -530 /* TTN_NEEDTEXT */)
                {
                    NMTTDISPINFO dispinfo = (NMTTDISPINFO)Marshal.PtrToStructure(msg.LParam, typeof(NMTTDISPINFO));
                    if ((dispinfo.uFlags & 0x20 /* TTF_TRACK */) != 0)
                    {
                        return(OnGetInfoTip(ShellBrowser.GetFocusedIndex(), true));
                    }
                    else
                    {
                        int i = GetHotItem();
                        if (i != -1 && IsTrackingItemName())
                        {
                            return(OnGetInfoTip(i, false));
                        }
                    }
                }
                break;
            }
            }
            return(false);
        }
Exemple #6
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case WM.LBUTTONUP:
                if (iHoveredIndex != -1)
                {
                    Point pt = QTUtility2.PointFromLPARAM(m.LParam);
                    Dictionary <int, Rectangle> dictionary2 = new Dictionary <int, Rectangle>(dicItemRcts);
                    foreach (Rectangle rect in from num in dictionary2.Keys
                             where num == iHoveredIndex select dicItemRcts[num])
                    {
                        if (rect.Contains(pt))
                        {
                            HideSwitcherInner(true, true);
                        }
                        break;
                    }
                }
                goto Label_01D5;

            case WM.DWMCOMPOSITIONCHANGED:
                SetCompositionState();
                goto Label_01D5;

            case WM.MOUSEACTIVATE:
                if ((QTUtility2.GET_Y_LPARAM(m.LParam) == 0x201) && (iHoveredIndex != -1))
                {
                    Point point = PointToClient(MousePosition);
                    Dictionary <int, Rectangle> dictionary = new Dictionary <int, Rectangle>(dicItemRcts);
                    foreach (int num in dictionary.Keys)
                    {
                        if (num == iHoveredIndex)
                        {
                            Rectangle rectangle = dicItemRcts[num];
                            if (rectangle.Contains(point))
                            {
                                Invalidate(dicItemRcts[num]);
                            }
                            break;
                        }
                    }
                }
                break;

            case WM.NCHITTEST:
                base.WndProc(ref m);
                switch (((int)m.Result))
                {
                case 10:
                case 11:
                case 12:
                case 13:
                case 14:
                case 15:
                case 0x10:
                case 0x11:
                    m.Result = (IntPtr)0x12;
                    return;
                }
                return;

            default:
                goto Label_01D5;
            }
            m.Result = (IntPtr)4;
            return;

Label_01D5:
            base.WndProc(ref m);
        }
        protected virtual bool ListViewController_MessageCaptured(ref Message msg)
        {
            if (msg.Msg == WM_AFTERPAINT)
            {
                RefreshSubDirTip(true);
                return(true);
            }

            switch (msg.Msg)
            {
            case WM.DESTROY:
                HideThumbnailTooltip(7);
                HideSubDirTip(7);
                ListViewController.DefWndProc(ref msg);
                OnListViewDestroyed();
                return(true);

            case WM.PAINT:
                // It's very dangerous to do automation-related things
                // during WM_PAINT.  So, use PostMessage to do it later.
                PInvoke.PostMessage(ListViewController.Handle, (uint)WM_AFTERPAINT, IntPtr.Zero, IntPtr.Zero);
                break;

            case WM.MOUSEMOVE:
                ResetTrackMouseEvent();
                break;

            case WM.LBUTTONDBLCLK:
                if (DoubleClick != null)
                {
                    return(DoubleClick(QTUtility2.PointFromLPARAM(msg.LParam)));
                }
                break;

            case WM.MBUTTONUP:
                if (MiddleClick != null)
                {
                    MiddleClick(QTUtility2.PointFromLPARAM(msg.LParam));
                }
                break;

            case WM.MOUSEWHEEL: {
                IntPtr handle = PInvoke.WindowFromPoint(QTUtility2.PointFromLPARAM(msg.LParam));
                if (handle != IntPtr.Zero && handle != msg.HWnd)
                {
                    Control control = Control.FromHandle(handle);
                    if (control != null)
                    {
                        DropDownMenuReorderable reorderable = control as DropDownMenuReorderable;
                        if ((reorderable != null) && reorderable.CanScroll)
                        {
                            PInvoke.SendMessage(handle, WM.MOUSEWHEEL, msg.WParam, msg.LParam);
                        }
                    }
                }
                break;
            }

            case WM.MOUSELEAVE:
                fTrackMouseEvent = true;
                HideThumbnailTooltip(4);
                if (((subDirTip != null) && !subDirTip.MouseIsOnThis()) && !subDirTip.MenuIsShowing)
                {
                    HideSubDirTip(5);
                }
                break;
            }
            return(false);
        }