I am making a small Visual C++ program. It's supposed to generate a random number, ask the user for a number, compare the number with the generated number, and open a new window telling the user if he is correct or incorrect.

Now, I am using a painted window to display output. in WM_PAINT, I first get the window's area, then paints a filled rectangle and text to the window's hdc (which I obtained in WM_CREATE using the GetDC function). The problem is, the window KEEPS on repainting itself and I ran out of GDI resources in like ten seconds. Does anyone know what caused this WM_PAINT loop?