Thread: mouse click coords and moving a rect

  1. #1
    Registered User
    Join Date
    Aug 2003

    mouse click coords and moving a rect

    I was wondering what a good way to get the difference between a rectangle's x, y position and a mouse click coord. I want to have something where you can click on a rectangle and move it, but the shape position is incremented by some difference of mouse x, y and shape x,y coords. Something like this is what I mean:
    				double dx = (e.getX()-shape.getX());
    				double dy = (e.getY()-shape.getY());

    the problem with this is that the shape then makes its position at the coord of the mouse click...Thanks alot!

    EDIT: This effect is like when you move an application window, the position of the window is relative to some difference of the mouse pos and its own xy.
    Last edited by techrolla; 03-07-2004 at 07:23 PM.
    you make me rery ascared

  2. #2
    You might want to look up ScreenToClient()..

Popular pages Recent additions subscribe to a feed