0

I learned, that DragDrop-Mode disables the mouse-move event in Winforms, have a look here: DoDragDrop disables MouseMove Events So I'm not sure if I have the same problem:

I have a UserControl with a Static selected Event:

    internal delegate void ProgramPartSelectedDelegate(ProgramPartControl sender, Point offset);

My idea is quite simple: After the user clicks on a Control, he can draw a line to the Point, where the Mouse is. Furthermore I tried to implement a half second of delay.

My Mouse-Move looks like this:

    void _form_MouseMove(object sender, MouseEventArgs e)
    {
        //System.Diagnostics.Debug.WriteLine("{0} {1} 1", this.GetType().Name, MethodBase.GetCurrentMethod().Name);

        Point p = new Point(e.X, e.Y);
        System.Diagnostics.Debug.WriteLine("p: {0} {1}, _point: {2} {3}", p.X, p.Y, _point.X, _point.Y);
        if (p != _point && _selectedPart != null)
        {
            System.Diagnostics.Debug.WriteLine("Start Timer");
            _point = p;
            _timerHelper.Start();
        }
    }

But as soon as the Control in _selectedPart gets set here:

    void ProgramPartControl_ControlSelected(ProgramPartControl sender, Point offset)
    {
        System.Diagnostics.Debug.WriteLine("Contol selected");
        _selectedPart = sender;
        _partOffset = offset;
    }

The mouse-move does not shoot again. Is this a problem of my tinkering or is this the same issue as with DragDrop? If this is a known problem, is there another solution than DragDrop? Basically I dont want to use this since I just want to check the Mouse-Pointer.

Thanks in advance

Community
  • 1
  • 1
Matthias Müller
  • 3,336
  • 3
  • 33
  • 65
  • If the mousemove is only attached to the form, it will not fire if the mouse moves over another control. Only the topmost control under the cursor would receive the mousemove notification (in winforms that is, wpf behaves differently). Could that be the problem you're facing? – Me.Name Apr 21 '14 at 18:19
  • I dont think so: I am hovring over the Main-Form, but as soon as the Pointer has been in the UserControl, it seems gone – Matthias Müller Apr 21 '14 at 18:56
  • Do you mean the mousemove isn't fired while over the usercontrol, or that it also doesn't fire anymore when the pointer is back over the form? – Me.Name Apr 22 '14 at 06:33
  • If you have a look in the Code above: The BOARD_MOUSEMOVE, so the event on the GUI itself, is fired, but as soon as ProgrampartControl_ControlSelected gets fired, the MouseMove doesn't shoot again. It seems like firing this event kindahow removes the Focus from the BOARD. I guess the mousedown-Event on the UC removes the BOARD-Focus. The question is, how can you override that without using DragNDrop, which would be overkill here. – Matthias Müller Apr 22 '14 at 08:09

0 Answers0