I draw some symbols, that belong to certain objects, into a device context and now want to be able to later test if the mouse cursor is above such a symbol.
To do this, my plan was to first create a CDC
path and use that to create a CRgn
region object.
pDC->BeginPath();
pDC->Ellipse(ellipse[0], ellipse[1], ellipse[2], ellipse[3]); // Create path only
pDC->EndPath();
// Actually draw the ellipse
pDC->StrokeAndFillPath(); // Apparently removes the path from the DC
CRgn region;
if (region.CreateFromPath(pDC)) // Would also remove the path from the DC
{
// We never get here :-/
// Here I would copy the region's data,
// attach it to the object being drawn and
// destroy the region.
// That way I can create a region later on and do the hit-testing.
}
How can I use the path for both, drawing and creating the region, without having to draw twice? Drawing twice pretty much doubles the time spent in my drawing method, which is something I'd like to avoid.