Example #1
0
        void cMS_MatchedGestures_MouseHover(object sender, EventArgs e)
        {
            foreach (IntPtr hwnd in m_hwndCmsList)
            {
                Win32.ShowWindow(hwnd, 0);
            }
            ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;

            if (menuItem.DropDownItems.Count > 0)
            {
                ToolStrip parent   = menuItem.GetCurrentParent();
                Point     position = parent.PointToClient(Cursor.Position);
                position.Y -= 2;
                //Debug.WriteLine(string.Format("cMS_MatchedGestures_MouseHover X: {0} Y: {1}", position.X, position.Y));
                int y = position.Y - (position.Y % menuItem.Height);
                y = y == 0 ? 0 : y + 2;
                int    x      = menuItem.Width;
                Point  newPos = parent.PointToScreen(new Point(x, y));
                IntPtr handle = menuItem.DropDown.Handle;
                Win32.SetWindowPos(handle, Win32.HWND_TOPMOST, newPos.X, newPos.Y,
                                   0, 0, Win32.SWP_SHOWWINDOW | Win32.SWP_NOACTIVATE | Win32.SWP_NOREDRAW);
            }
        }