I'm trying to draw a button based on the images. The button should have 3 pictures:
- 1.png - normal state,
- 2.png - mouse hover state,
- 3.png - mouse down state.
Also in the handler for WM_MOUSEMOVE I set _TrackMouseEvent.
Ok. To do that I write the following code in the window procedure:
- For the normal button state:
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
Gdiplus::Graphics *normal_state = new Gdiplus::Graphics(ps.hdc);
Image *img = new Image(L"d:/images/1.png",false);
normal_state->DrawImage(img,5,5);
delete img;
delete normal_state;
EndPaint(hwnd, &ps);
}
It works perfectly.
And now I'm trying to to make realization for mouse hover state:
case WM_MOUSEHOVER:
{
PAINTSTRUCT ps;
BeginPaint(hwnd,&ps);
Gdiplus::Graphics *mousehover_state = new Gdiplus::Graphics(ps.hdc);
Image *img = new Image(L"d:/images/2.png",false);
mousehover_state->DrawImage(img,5,5);
delete img;
delete mousehover_state;
EndPaint(hwnd,&ps);
}
But in the final result WM_MOUSEHOVER fired, but the new picture is not drawn - this is a problem number 1.
Problem number 2 - how to erase the image of the old button state before the painting image for new button state?
Thanks!