Why do you use a movement based on the old and new window sizes ?

Can't you just calculate a new position based on the new size ? So always calculate an absolute position, not a relative position compared to the old position. That would be much less error-prone.

Regards,
Marc