0
votes

im trying to display image when left mouse button is down.
i can display the image but if the left mouse button is down again than the older image would be deleted.
here is my code
display image function

{
    Graphics graphics(hdc);
    POINT pt;
    GetCursorPos(&pt);
    ScreenToClient(hWnd, &pt);
    Image shot(L"RegularShots.png");
    graphics.DrawImage(&shot, pt.x, pt.y);
}

left mouse button down

case WM_LBUTTONDOWN:
    RegularShots=0;
    InvalidateRect(hWnd, rect, false);
    break;

wm_paint

case WM_PAINT:
    hdc = BeginPaint(hWnd, &ps);
    OnPaint(hdc, hWnd, 1);
    if(RegularShots==0)
    {
        RegularShot(hdc, hWnd);
    }
    EndPaint(hWnd, &ps);
    break;

anyideas?

1

1 Answers

0
votes

You need to store a collection (array / vector etc.) of coordinates that is added to each time the mouse button is pressed - and then when rendering in WM_PAINT, draw an image at each of these locations.