Meet the Robinsons
(2007)

The boy, Lewis, actually is transported to the future by his son.  Lewis realizes he must fix the time machine (as a child) and return to the present.  He does this,  and then takes "Bowler Hat Man" (AKA his orphanage roommate) to the future and showing him how evil Doris (the hat) had become.   "Bowler Hat Man" agrees and Lewis says he will never invent Doris the hat.  Lewis goes back to the present day and is adopted by the family seen in the future and his life is set.

Thanks Christine!