Moving paint object with keyboard input

Qobacha

New member
Joined
Apr 28, 2012
Messages
2
Programming Experience
Beginner
Hi Everyone

I have drawn a square on the screen/form using GDI. Now I want to move this object around using keyboard inputs. I just want it to move along the x-axis using left and right arrow keys. I can assign the keys but the problem is making that object move. Please help me on this
 
I would suggest that you check this out regarding keyboard input:

Keyboard Events in Windows Forms

Perhaps you're already doing things the right way but maybe not. Even if you are, I'll wager that you'll find something in there that you didn't know and may be able to use some other time.

As for moving the drawing, you should check this out:

Manipulating GDI+ Drawings

It shows how to move GDI+ drawings using drag & drop but moving is moving and how you calculate how far to move is irrelevant to that process.
 
Thanks the problem is solved. Used key-down event and increased velocity of the object by +/- depending on the direction.
 
Back
Top Bottom