Fixed bug when the windows is minimized and restored again.
It turns out that the HDC is not the same format.

Also refactored the scoped context to be able to see the errors, more easily