Windows background color
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:
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?
sBrush.lbStyle = BS_SOLID;
sBrush.lbColor = RGB(0, 0, 255);
sBrush.lbHatch = 0;
hBrush = CreateBrushIndirect(&sBrush);
SetClassLong(Handle, GCL_HBRBACKGROUND, (long)hBrush);
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.
>>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.<<
If you're using a non-system, non-shared brush then create it once and don't forget to DeleteObject on it when done.
InvalidateRect justs adds the given rectangle to the update region for rendering with the next WM_PAINT message which is usually okay. If you need to force a WM_PAINT then use UpdateWindow; RedrawWindow. may also be of some interest.
That works, I figured there was an API to do it. Drawing a big rectangle works. Thanks for the help.