Treatment of mouse WinAPI

The question was asked: 7 years 4 months ago   views: 31

Actually, I have such a task: draw in the window, some shapes, and get them to flash a colour when you press them. How to treat depression on a specific figure?

Asked: 10-04-2012 в 00:58:43
Track mouse coordinates, when you click see anywhere, pererisovyvali the scene in new colors. - 10-04-2012 в 01:59:41

Answers   2


Need to handle a mouse click in the window, WM_LBUTTONDOWN for example, to look for the coordinates of the figure, which hit and redraw it in a different color. Do not forget to draw back the right color.

Answered: 10-04-2012 в 09:40:59

If you use WinAPI, it is possible to provide figures in the form of regions (CreateRectRgn, CreateEllipticRgn, CreatePolygonRgn). Function PtInRegion checks whether the point in the region, and how to find the coordinates of the desired point, you wrote above: processing message WM_LBUTTONDOWN.

Answered: 10-04-2012 в 14:08:28