As a matter of fact, I have such a task: draw some shapes in the window and make them blink in color when you click on them. How to handle clicking on a specific shape?

  • Track the coordinates of the mouse, when you click to see where you got, redraw the scene in new colors. - Yura Ivanov

2 answers 2

It is necessary to process a mouse click in the window, for example WM_LBUTTONDOWN, search for the coordinates of the figure that you hit and redraw it with a different color. Then do not forget to draw back the right color.

    If WinAPI is used, then you can represent the shapes as regions ( CreateRectRgn , CreateEllipticRgn , CreatePolygonRgn ). The PtInRegion function checks whether a point is in a region, and how to find the coordinates of the desired point, you have already been written above: processing the WM_LBUTTONDOWN message.