add basic error handling for system calls

using FormatMessageW with GetLastError and MessageBoxW
optimized drawing code

Invalidating only a rectangle with the size of the dot to be repainted
to avoid flickering and delay in drawing when more dots are to be drawn