Dealing with Multiple Instances

Normally, Windows programs reuse the same window class when you load multiple instances of the program. The window class is registered only if the previous instance is NULL:

if (!hPrevInstance)

{

wndclass.style = CS_HREDRAW | CS_VREDRAW ;

[more program lines]

But COLORS1 can't do this, because the background color is specified in the window class. If all instances of COLORS1 used the same window class, then each instance would use (and change) the same background color. We can avoid this problem entirely by allowing only one instance of COLORS1 to run:

if (hPrevInstance)

return FALSE ;