Your question is short, but the answer heavily depends on how much math knowledge you have.
Possibly the biggest tip I can give anyone who ever wants to deal with graphics is to go back you your end-of-school (ie A-level) math books, and learn about matrices (matrix-es) and vectors. It's fine if you don't know it now. If you are unwilling or unable to do this, quit now and start learning how to say "would you like fries with that?".
If you don't already know about it, I'd advise you learn about SetROP2(R2_NOT) for your mouse handling code, to draw / undraw tracking lines.
I hope that helps steer you in the right direction. A more exact answer would depend on the details of your application and skill level.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[^]
to add to warrior panda's reply :p, you can try [this] to understand vectors. Once you know that, you should not have any problem calculating angles or rotating a rectangle. you just need to specify the rotate center and angle of rotation and then rotate each of the 4 vectors obtained by joining rotate center and 4 corners. easy, huh?
1. get the coordinates of the two points on the 'top' edge. (this assumes one of them is the anchor point of the rotation)
2. find the change in x and change in y (dx and dy)
3. use atan(dy/dx) (or atan2(dy/dx)) to find the angle in radians of the line that connects them