I am on GNU/Linux so I didn't test the program.
But I am supposing that it is because of the message loop, stopping a bit the program.
The problem is certainly that for each pixel, the message loop receives one message. So if you are moving, let's say, 1000 pixels, you have 1000 messages to process (Wow ... a lot).