Learn how to write the code for calculating how far the mouse has moved relative to the position at which the mouse button was pressed.
- [Instructor] Now there is one more event of interest here,…the movement of the mouse itself,…so we can track its position across the panel.…So let's go to the designer.…With the panel selected.…Go to the event's dialogue,…the properties dialog where it says Events.…And we look for MouseMove.…I'll double click MouseMove.…And it generates the event handler for me.…Now in here we want to keep track…of the position of the cursor.…The position of the mouse cursor…is available from windows forms.…
In this case, the e variable has the position…both as an X and as a Y variable,…and it will use this to calculate the difference between…the position of the mouse once the button is depressed…and the position of the mouse…while the mouse is moving over the panel itself.…So, what do I mean?…So, on mouse down, we want to keep track…of the position where the mouse started.…There many ways to do this,…I'm just using this as a reference point.…So, once the mouse is pressed…based on where you start the mouse down action,…then the distance that you move it,…
Skill Level Intermediate
1. Problem 1: Pond Oreille
2. Problem 2: Where Am I?
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Facial Recognition
6. Problem 6: Real-Time Information Dashboard
Next steps2m 46s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.