【发布时间】:2010-12-09 12:12:42
【问题描述】:
我在设备上下文中绘制了一些属于某些对象的符号,现在希望能够稍后测试鼠标光标是否在此类符号上方。
为此,我的计划是首先创建一个CDC 路径并使用它来创建一个CRgn 区域对象。
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.
}
如何在绘制和创建区域时同时使用路径,而不必绘制两次?绘制两次几乎使我的绘制方法所花费的时间翻了一番,这是我想避免的。
【问题讨论】: