I think that simply saying so when the topic comes up is a good idea. They say, "Oh, we came by and you weren't home"? Then you say, "Oh, really. Well, that's one reason you should call first. And in general, since we're talking about this, I want to let you know that we really would prefer for you to call us first to make sure it's a good time to visit. Sometimes we're really too busy for company, and even if we aren't, we like a little bit of warning."
Then, if they don't get the message, repeat it when the drop-by happens. And don't change your plans in the tiniest bit. If you're cleaning out the closet when they drop by, and you decide to let them in (which I would do--turning them away at the door is not on my polite list), then keep cleaning the closet. Be abstracted and busy, so the visit isn't rewarding. And say, "If you had called, I'd have been able to change my plans to spend more time with you."