I'm trying to change the color of a rectangle in runtime:
Code:
// Global
COLORREF clr;
// WndProc
case WM_CREATE:
clr = RGB(255, 255, 255); // Color init of the rectangle
case WM_COMMAND:
/*
Calls ChooseColor dialog and pass
hWnd: the parent handle
&clr: buffer to the new color
clr: current color
*/
if (ColorDLG(hWnd, &clr, clr)) InvalidateRect(hWnd, NULL, FALSE);
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
hbrush = CreateSolidBrush(clr);
HBRUSH hbrOld = (HBRUSH)SelectObject(hdc, hbrush);
Rectangle(hdc, 10, 10, 80, 60);
SelectObject(hdc, hbrOld);
DeleteObject(hbrOld);
DeleteObject(hbrush);
EndPaint(hWnd, &ps);
The problem is that the color of the rectangle changes when I minimizad the window, not instantly..any ideas?