You forgot the break after the WM_PAINT of your control. That causes the problem (though I don't know how).