Read Programming Windows by Charles Petzold and this'll be a doddle.