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?
2 answers
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.
|