Advertisement
theiotlord

Moving Form Function [C#]

Nov 17th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. public static Point newpoint = new Point();
  2. public static int x;
  3. public static int y;
  4.  
  5. // Mouse down
  6. YOURFORMNAME.x = Control.MousePosition.X - base.Location.X;
  7. YOURFORMNAME.y = Control.MousePosition.Y - base.Location.Y;
  8.  
  9. // Mouse Move
  10. if (e.Button == MouseButtons.Left)
  11. {
  12. YOURFORMNAME.newpoint = Control.MousePosition;
  13. YOURFORMNAME.newpoint.X -= YOURFORMNAME.x;
  14. YOURFORMNAME.newpoint.Y -= YOURFORMNAME.y;
  15. base.Location = YOURFORMNAME.newpoint;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement