Implemented double buffering for WM_PAINT