Show your code. Hard to guess your problem without it.
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
Shift the coordinates with half the width and half the height.
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
When you assign a new left and top, you can check whether or not it falls of the panel. If so, do not update the left and top.
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874