Peanuts used to be friendly to strangers. She would sniff at them to a point that it makes the strangers comfortable. But when she grew up, she expected people to play with her. So every time a visitor would arrive, she would bark at them excessively and put on the play bow stance. And it's just hilarious but at times, annoying.
Anyway, if the treats doesn't work. Here's one more trick you can try. When you approach the dog, don't go full frontal on him. Approach him by walking sideways while averting your eyes away from him (your head a bit lowered). If he doesn't growl on you, then that's a good sign (make sure to check for tell-tale signs of aggression too. This link has pictures of how to determine an aggressive dog). Then allow him to sniff you. That's how dogs introduce themselves to one another. If you see him wagging his tail (without bared teeth/ raised hackles/ low growl), you can lower to his level and give him a good stroke.