void RequestMouseLeaveMessage(IntPtr hWnd) { // Crea the structure needed for WindowsAPI call Win32.TRACKMOUSEEVENTS tme = new Win32.TRACKMOUSEEVENTS(); // Fill in the structure tme.cbSize = 16; tme.dwFlags = (uint)Win32.TrackerEventFlags.TME_LEAVE; tme.hWnd = hWnd; tme.dwHoverTime = 0; // Request that a message gets sent when mouse leaves this window WindowsAPI.TrackMouseEvent(ref tme); }
/// <exclude/> protected override void OnMouseHover(EventArgs e) { base.OnMouseHover(e); IDockContent content = GetHitTest(); if (content != null && DockPanel.ActiveAutoHideContent != content) { DockPanel.ActiveAutoHideContent = content; } // requires further tracking of mouse hover behavior, // call TrackMouseEvent Win32.TRACKMOUSEEVENTS tme = new Win32.TRACKMOUSEEVENTS(Win32.TRACKMOUSEEVENTS.TME_HOVER, Handle, Win32.TRACKMOUSEEVENTS.HOVER_DEFAULT); User32.TrackMouseEvent(ref tme); }
protected override void OnMouseMove(MouseEventArgs e) { // Sometimes we need to ignore this message if (_ignoreMouseMove) _ignoreMouseMove = false; else { // Is the first time we have noticed a mouse movement over our window if (!_mouseOver) { // Crea the structure needed for WindowsAPI call Win32.TRACKMOUSEEVENTS tme = new Win32.TRACKMOUSEEVENTS(); // Fill in the structure tme.cbSize = 16; tme.dwFlags = (uint)Win32.TrackerEventFlags.TME_LEAVE; tme.hWnd = this.Handle; tme.dwHoverTime = 0; // Request that a message gets sent when mouse leaves this window WindowsAPI.TrackMouseEvent(ref tme); // Yes, we know the mouse is over window _mouseOver = true; } Form parentForm = this.FindForm(); // Only hot track if this Form is active if ((parentForm != null) && parentForm.ContainsFocus) { Point pos = new Point(e.X, e.Y); int i = 0; for(i=0; i<_drawCommands.Count; i++) { DrawCommand dc = _drawCommands[i] as DrawCommand; // Find the DrawCommand this is over if (dc.DrawRect.Contains(pos)) { // Is there a change in selected item? if (_trackItem != i) { // We we currently selecting an item if (_selected) { if (_popupMenu != null) { // Note that we are dismissing the submenu but not removing // the selection of items, this flag is tested by the routine // that will return because the submenu has been finished _dismissTransfer = true; // Dismiss the submenu _popupMenu.Dismiss(); // Default to downward drawing _drawUpwards = false; } // Modify the display of the two items _trackItem = SwitchTrackingItem(_trackItem, i); // Does the newly selected item have a submenu? if (dc.Chevron || (dc.MenuCommand.MenuCommands.Count > 0)) WindowsAPI.PostMessage(this.Handle, WM_OPERATEMENU, 1, 0); } else { // Modify the display of the two items _trackItem = SwitchTrackingItem(_trackItem, i); } } break; } } // If not in selected mode if (!_selected) { // None of the commands match? if (i == _drawCommands.Count) { // Modify the display of the two items _trackItem = SwitchTrackingItem(_trackItem, -1); } } } } base.OnMouseMove(e); }
protected void OnWM_MOUSEMOVE(ref Message m) { // Are we a submenu? if (_parentMenu != null) { // Inform parent that we have movement and so do not // use a timer to close us up _parentMenu.SubMenuMovement(); } // Is the first time we have noticed a mouse movement over our window if (!_mouseOver) { // Crea the structure needed for WindowsAPI call Win32.TRACKMOUSEEVENTS tme = new Win32.TRACKMOUSEEVENTS(); // Fill in the structure tme.cbSize = 16; tme.dwFlags = (uint)Win32.TrackerEventFlags.TME_LEAVE; tme.hWnd = this.Handle; tme.dwHoverTime = 0; // Request that a message gets sent when mouse leaves this window WindowsAPI.TrackMouseEvent(ref tme); // Yes, we know the mouse is over window _mouseOver = true; } // Extract the mouse position int xPos = (int)((uint)m.LParam & 0x0000FFFFU); int yPos = (int)(((uint)m.LParam & 0xFFFF0000U) >> 16); Point pos = new Point(xPos, yPos); // Has mouse position really changed since last time? if (_lastMousePos != pos) { for(int i=0; i<_drawCommands.Count; i++) { DrawCommand dc = _drawCommands[i] as DrawCommand; if (dc.DrawRect.Contains(pos)) { // Is there a change in selected item? if (_trackItem != i) { // Modify the display of the two items SwitchSelection(_trackItem, i, true, false); } } } // Remember for next time around _lastMousePos = pos; } }
/// <exclude/> protected override void OnMouseHover(EventArgs e) { base.OnMouseHover(e); IDockContent content = GetHitTest(); if (content != null && DockPanel.ActiveAutoHideContent != content) DockPanel.ActiveAutoHideContent = content; // requires further tracking of mouse hover behavior, // call TrackMouseEvent Win32.TRACKMOUSEEVENTS tme = new Win32.TRACKMOUSEEVENTS(Win32.TRACKMOUSEEVENTS.TME_HOVER, Handle, Win32.TRACKMOUSEEVENTS.HOVER_DEFAULT); User32.TrackMouseEvent(ref tme); }