/// <summary> /// Method called when timer event occurs /// </summary> /// <param name="sender">sender</param> /// <param name="e">e</param> private void OnTimer(object sender, EventArgs e) { if (Visible == false || Parent == null) { return; } Point mousePosition = MousePosition; MouseButtons button = MouseButtons; bool invalidate = false; if (PerformCaptureReplace(mousePosition, button)) { return; } if (AutoButtonScreenBounds.Contains(mousePosition)) { if (_mouseIsOverAutoButton == false) { _mouseIsOverAutoButton = true; invalidate = true; } } else if (_mouseIsOverAutoButton) { _mouseIsOverAutoButton = false; invalidate = true; } if (MenuButtonScreenBounds.Contains(mousePosition)) { if (_mouseIsOverMenuButton == false) { _mouseIsOverMenuButton = true; invalidate = true; } } else if (_mouseIsOverMenuButton) { _mouseIsOverMenuButton = false; invalidate = true; } if (invalidate) { InvalidateForm(); } else { _timer.Interval = 10000; } }
/// <summary> /// Method for handling the form messages loop /// </summary> /// <param name="m">message to be handled</param> protected override void WndProc(ref Message m) { base.WndProc(ref m); if (_disposed) { return; } int message = (int)m.Msg; Point cursorPos = MousePosition; MouseButtons button = MouseButtons; switch (message) { case SYSCOMMAND: { if (AutoButtonScreenBounds.Contains(cursorPos)) { if (AutoHideButtonClick != null && _mouseIsOverAutoButton) { AutoHideButtonClick(this, EventArgs.Empty); } } if (MenuButtonScreenBounds.Contains(cursorPos)) { if (ContextMenuForToolWindow != null && _mouseIsOverMenuButton) { ContextMenuForToolWindow(this, EventArgs.Empty); } } } break; case NCMOUSEMOVE: _timer.Interval = 10; break; case MOVING: case NCLBUTTONDOWN: case LBUTTONDOWN: case SETCURSOR: case NCLBUTTONDBLCLK: if (IsDocked && Parent != null && Capture && TitleBarScreenBounds.Contains(MousePosition)) { // Call get text allows releasing the capture. Let this line here string text = Text; _lastNCMouseDownPos = cursorPos; _lastPosOnNcMouseDown = Parent.PointToScreen(Location); _captureSuspended = true; Capture = false; _timer.Interval = 10; } break; case EXITSIZEMOVE: InvalidateForm(); break; case NCLBUTTONUP: _captureSuspended = false; _captureReplaceStarted = false; break; case NCACTIVATE: case NCPAINT: case PAINT: case SETTEXT: DrawExtraButtons(m.HWnd); break; } }