I’m creating a win32 application. on the main window there are 5 buttons. in front of each button there is a small circle drawn. (using GDI tools. in case WM_PAINT). now when I press on a button the circle in front of it should colour in red colour. how can I do this.
If we create a edit box any time we can change the text on it using SendMessege to it. like that is it possible to change the colour on shapes drawn earlier.
Please can someone give me an advice.
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hDC;
HBRUSH brusha;
hDC=BeginPaint(hWnd,&ps);
brusha=CreateSolidBrush(RGB(0,255,0));
SelectObject(hDC,brusha);
Ellipse(hDC, 20, 20, 50, 50);
DeleteObject(brusha);
EndPaint(hWnd, &ps);
}
case WM_COMMAND:
switch(LOWORD(wParam))
{
case BUTTON:
{
//here I need to change the above drawn corcle to be red.
}
}
You can’t change the color of an already drawn image, but you can redraw it. Use the Windows function
InvalidateRectto tell the control that it needs to be redrawn, and you will get another call to yourWM_PAINThandler. In the handler select the desired color before you draw your circle.