The progam I am using has multiple windows with that use the same window class. I would like to be able to individually change their background colors. However, the only way I've been successful is by changing the background color in the window class:
Code:
HBRUSH hBrush;
LOGBRUSH sBrush;
sBrush.lbStyle = BS_SOLID;
sBrush.lbColor = RGB(0, 0, 255);
sBrush.lbHatch = 0;
hBrush = CreateBrushIndirect(&sBrush);
SetClassLong(Handle, GCL_HBRBACKGROUND, (long)hBrush);
DeleteObject(hBrush);
That changes the colors in all the windows with that class. I've read a few things that suggest the WM_ERASEBKGND message might be useful here, but I haven't found any examples of it in use. How can this be generated on demand, InvalidateRect(Handle, NULL, TRUE)? And how would it be used to change the background color?
Is there any other way to change the background color of a window without impacting any other windows? I was expecting an API call of some sort for this, considering how easy it is in VB, guess that'll teach me to try to compare VB and C functionality.