// Find the element at the cursor CElement* CSketcherView::SelectElement( CPoint aPoint) { // Convert parameter aPoint to logical coordinates CClientDC aDC(this); OnPrepareDC(&aDC); aDC.DPtoLP(&aPoint); CSketcherDoc* pDoc=GetDocument(); CElement* pElement = 0; CRect aRect(0,0,0,0); POSITION aPos = pDoc->GetListTailPosition(); while(aPos) { pElement = pDoc->GetPrev(aPos); aRect = pElement->GetBoundRect(); // Select the first element that appears under the cursor if ( aRect.PtInRect(aPoint) ) return pElement; } return NULL; }