I'm trying to draw a selection box while the user moves the mouse

The problem is that I need the previous box to be deleted without erasing the content of the background.

Can anyone help me with that please?


Thanx