Edit:
Simple code I used to solve the problem in case anyone is interested (thanks to Fredrik):
int windowOverlap(Rectangle rect1, Rectangle rect
Sounds like basic Collision Detection. Have you looked at this page on Wikipedia?
Mike
edit: Fredrik make his response at the same time I made this one, his answer got my upvote ( :