. . . "You have a lovely wife." (and that sort of comment) is actually an insult!
The one saying it to you is expressing their disbelief in the fact that such a "lovely" woman would ever have anything to do with you...
The "Thank you"-response only shows that you also find it quite unbelievable that such a person would have anything to do with you -AND implies that you have (had?) some kind of special mojo that got her attention at the time...
Well, that's a bit of a stretch, isn't it?
I may be over-analyzing the meaning of saying thanks to one of those compliments to you about something you had no influence on.
But the first half of my argument I stand by.