Creating a color gradient as a background isn't hard at all. If you have read Nishant's article on using color gradients with MFC, then this code is simply a modified SDK version of his article.
Into the abyss we go
Okay, first I suggest reading the MFC version of this.
After that you should have a simple understanding of how this was done. To get started, simply add the
WM_ERASEBKGND message to your window procedure function. I suggest creating a separate function to do all the work of actually drawing the background. If this is the route you decide to take, make sure in the declaration of the function you pass along the handle to your main window. With this said, now for the code.
void OnEraseBkGnd(HWND hwnd)
RECT rect, temp;
dc = GetDC(hwnd);
int r1 = 255, g1 = 0, b1 = 0;
int r2 = 255, g2 = 255, b2 = 0;
r = r1 + (i * (r2-r1) / rect.right);
g = g1 + (i * (g2-g1) / rect.right);
b = b1 + (i * (b2-b1) / rect.right);
temp.left = i;
temp.top = 0;
temp.right = i + 1;
temp.bottom = rect.bottom;
color = CreateSolidBrush(RGB(r, g, b));
FillRect(dc, &temp, color);
One last final note, now that wasn't hard, was it? Its really easy to create a gradient. Also if you create a second function for creating the gradient, you could just easily call the function when you wanted the gradient to appear. Also with a little bit of customization you could easily make the gradient only a portion of the window. That's all folks...