예제 #1
0
        public static IntPtr SendCOPYDATASTRUCT(IntPtr hWnd, IntPtr wParam, string strMsg, IntPtr dwData)
        {
            if ((strMsg == null) || (strMsg.Length == 0))
            {
                strMsg = "null";
            }
            QTTabBarLib.Interop.COPYDATASTRUCT structure = new QTTabBarLib.Interop.COPYDATASTRUCT();
            IntPtr hglobal = Marshal.StringToHGlobalUni(strMsg);

            structure.lpData = hglobal;
            structure.cbData = (strMsg.Length + 1) * 2;
            structure.dwData = dwData;
            IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure));

            Marshal.StructureToPtr(structure, ptr, false);
            IntPtr ptr3 = PInvoke.SendMessage(hWnd, WM.COPYDATA, wParam, ptr);

            Marshal.FreeHGlobal(hglobal);
            Marshal.FreeHGlobal(ptr);
            return(ptr3);
        }
예제 #2
0
 private static IntPtr SendCOPYDATASTRUCT_IDL(IntPtr hWnd, IntPtr wParam, byte[] idl, IntPtr dwData) {
     if((idl == null) || (idl.Length == 0)) {
         return (IntPtr)(-1);
     }
     QTTabBarLib.Interop.COPYDATASTRUCT structure = new QTTabBarLib.Interop.COPYDATASTRUCT();
     int length = idl.Length;
     IntPtr destination = Marshal.AllocHGlobal(length);
     Marshal.Copy(idl, 0, destination, length);
     structure.lpData = destination;
     structure.cbData = length;
     structure.dwData = dwData;
     IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure));
     Marshal.StructureToPtr(structure, ptr, false);
     IntPtr ptr3 = PInvoke.SendMessage(hWnd, 0x4a, wParam, ptr);
     Marshal.FreeHGlobal(destination);
     Marshal.FreeHGlobal(ptr);
     return ptr3;
 }
예제 #3
0
 private static IntPtr SendCOPYDATASTRUCT_IDL(IntPtr hWnd, IntPtr wParam, byte[] idl, IntPtr dwData) {
     if((idl == null) || (idl.Length == 0)) {
         return (IntPtr)(-1);
     }    
     int length = idl.Length;
     using(SafePtr destination = new SafePtr(length)) {
         Marshal.Copy(idl, 0, destination, length);
         COPYDATASTRUCT structure = new COPYDATASTRUCT { lpData = destination, cbData = length, dwData = dwData };
         return PInvoke.SendMessage(hWnd, 0x4a, wParam, ref structure);
     }
 }
예제 #4
0
        protected override void WndProc(ref Message m)
        {
            try {
                QMenuItem ownerItem;
                if (!this.fRespondModKeys)
                {
                    base.WndProc(ref m);
                    return;
                }
                int wParam = (int)((long)m.WParam);
                switch (m.Msg)
                {
                case WM.KEYDOWN:
                    break;

                case WM.KEYUP:
                    if (this.fOnceKeyDown && ((wParam == 0x10) || (wParam == 0x11)))
                    {
                        bool flag2 = false;
                        foreach (QMenuItem item4 in this.lstQMIResponds)
                        {
                            if (!item4.Selected)
                            {
                                continue;
                            }
                            if (item4.Enabled)
                            {
                                Keys modifierKeys = Control.ModifierKeys;
                                if (modifierKeys == Keys.Control)
                                {
                                    item4.ImageKey = "control";
                                }
                                else if (this.fEnableShiftKey && (modifierKeys == Keys.Shift))
                                {
                                    item4.ImageKey = "shift";
                                }
                                else
                                {
                                    item4.RestoreOriginalImage(this.fChangeImageSelected, false);
                                }
                                this.lastKeyImageChangedItem = item4;
                            }
                            flag2 = true;
                            break;
                        }
                        ownerItem = base.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 (this.fSuspendPainting)
                    {
                        PInvoke.ValidateRect(m.HWnd, IntPtr.Zero);
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    return;

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

                default:
                    goto Label_07C2;
                }
                this.fOnceKeyDown = true;
                if ((((int)((long)m.LParam)) & 0x40000000) == 0)
                {
                    if ((wParam == 0x10) || (wParam == 0x11))
                    {
                        bool flag = false;
                        foreach (QMenuItem item2 in this.lstQMIResponds)
                        {
                            if (!item2.Selected)
                            {
                                continue;
                            }
                            if (item2.Enabled)
                            {
                                Keys keys = Control.ModifierKeys;
                                if ((wParam == 0x11) && ((keys & Keys.Shift) != Keys.Shift))
                                {
                                    item2.ImageKey = "control";
                                }
                                else if ((this.fEnableShiftKey && (wParam == 0x10)) && ((keys & Keys.Control) != Keys.Control))
                                {
                                    item2.ImageKey = "shift";
                                }
                                else
                                {
                                    item2.RestoreOriginalImage(this.fChangeImageSelected, false);
                                }
                                this.lastKeyImageChangedItem = item2;
                            }
                            flag = true;
                            break;
                        }
                        ownerItem = base.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) && ((this.fEnableShiftKey && (Control.ModifierKeys == Keys.Shift)) || (Control.ModifierKeys == Keys.Control)))
                    {
                        foreach (ToolStripItem item3 in this.Items)
                        {
                            if (item3.Selected)
                            {
                                if (item3.Enabled)
                                {
                                    this.OnItemClicked(new ToolStripItemClickedEventArgs(item3));
                                }
                                break;
                            }
                        }
                    }
                }
                goto Label_07C2;
Label_0462:
                ownerItem = base.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 = Control.ModifierKeys;
                    if (keys4 == Keys.Control)
                    {
                        ownerItem.ImageKey = "control";
                    }
                    else if (this.fEnableShiftKey && (keys4 == Keys.Shift))
                    {
                        ownerItem.ImageKey = "shift";
                    }
                    else
                    {
                        ownerItem.RestoreOriginalImage(this.fChangeImageSelected, false);
                    }
                    this.lastKeyImageChangedItem = ownerItem;
                }
                else
                {
                    ownerItem = base.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 == this.lparamPreviousMouseMove))
                {
                    m.Result = IntPtr.Zero;
                    return;
                }
                this.lparamPreviousMouseMove = m.LParam;
                if ((!this.fEnableShiftKey || ((wParam & 4) != 4)) && (((wParam & 8) != 8) && !this.fChangeImageSelected))
                {
                    goto Label_07C2;
                }
                ToolStripItem itemAt = base.GetItemAt(new Point(QTUtility2.GET_X_LPARAM(m.LParam), QTUtility2.GET_Y_LPARAM(m.LParam)));
                if (itemAt == null)
                {
                    base.WndProc(ref m);
                    return;
                }
                ownerItem = itemAt as QMenuItem;
                if (!IsQmiResponds(ownerItem))
                {
                    goto Label_06F8;
                }
                if (ownerItem == this.lastMouseActiveItem)
                {
                    goto Label_07C2;
                }
                if (this.lstQMIResponds.Count > 0x1c)
                {
                    this.fSuspendPainting = true;
                }
                base.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 (this.lastMouseActiveItem != null)
                {
                    this.lastMouseActiveItem.RestoreOriginalImage();
                }
                if ((ownerItem != this.lastKeyImageChangedItem) && (this.lastKeyImageChangedItem != null))
                {
                    this.lastKeyImageChangedItem.RestoreOriginalImage();
                    this.lastKeyImageChangedItem = null;
                }
                this.lastMouseActiveItem = ownerItem;
                this.fSuspendPainting    = false;
                base.ResumeLayout(false);
                goto Label_07C2;
Label_06F8:
                if (this.lastMouseActiveItem != null)
                {
                    this.lastMouseActiveItem.RestoreOriginalImage();
                    this.lastMouseActiveItem = null;
                }
                if (this.lastKeyImageChangedItem != null)
                {
                    this.lastKeyImageChangedItem.RestoreOriginalImage();
                    this.lastKeyImageChangedItem = null;
                }
                goto Label_07C2;
Label_072E:
                this.ResetImageKeys();
                if (this.lastMouseActiveItem != null)
                {
                    this.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);
            this.fSuspendPainting = false;
        }