Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Point mouseOffset;
- private bool isMouseDown = false;
- private void frmTest_MouseDown(object sender, MouseEventArgs e)
- {
- int xOffset;
- int yOffset;
- if (e.Button == MouseButtons.Left)
- {
- xOffset = -e.X - SystemInformation.FrameBorderSize.Width;
- yOffset = -e.Y - SystemInformation.CaptionHeight -
- SystemInformation.FrameBorderSize.Height;
- mouseOffset = new Point(xOffset, yOffset);
- isMouseDown = true;
- }
- }
- private void frmTest_MouseMove(object sender, MouseEventArgs e)
- {
- if (isMouseDown)
- {
- Point mousePos = Control.MousePosition;
- mousePos.Offset(mouseOffset.X, mouseOffset.Y);
- Location = mousePos;
- }
- }
- private void frmTest_MouseUp(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- isMouseDown = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement