I don't think the first ::CopyRect is necessary. It copies rect to dest, then ::UnionRect overwites the value you just put in dest. I think you can safely remove that line.