views:

70

answers:

0

Hi! I want move control in another control. It's very simple code

    private void ControlThumb_MouseDown(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            m_offSet = Control.MousePosition; 
            ((Control)sender).Capture = true;

        }
    }

    private void ControlThumb_MouseMove(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            Point point = new Point(Control.MousePosition.X, Control.MousePosition.Y);
            point.Offset(-m_offSet.X, -m_offSet.Y);
            ControlThumb.Location = new Point(ControlThumb.Location.X + point.X,    ControlThumb.Location.Y);;
            m_offSet = Control.MousePosition;
        }
    }
    private void ControlThumb_MouseUp(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            ((Control)sender).Capture = false;
        }
    }

Control move but cursor lags behind the control. And when i stop moving mouse cursor off the control. Sorry for my english :)