Okay, it's supposed to be really simple to run your game in both exclusive mode and windowed mode, but it does take some work to get it running properly (and elegantly). For this article, I'll be using C++ because it's very common in the industry. You can wrap this example in classes to make it easier, if that's what you want.
I'm also assuming that you're familiar with setting up and using DirectDraw in exclusive mode, so I won't go into the details of that here. Read on!