Hit-Testing Components
New functionality has been added to SRGraphRect and SRGraphComponent to facilitate hit-testing on component rectangles (including SRGraphLabel and SRGraphLabelBlock which are not rectangle based).
The code below demonstrates how GetLogRect() can be used to determine which component was clicked by the user.
void CResizeTestView::OnLButtonDown(UINT nFlags, CPoint point)
for(POSITION p=GetGraph()->GetComponentList()->GetHeadPosition(); p!=NULL;)
SRGraphComponent *pC=
(SRGraphComponent *)GetGraph()->GetComponentList()->GetNext(p);
CRect r=pC->GetLogRect();
UINT type = pC->GetType();
CString sText;
if(type == IDS_SRG_TITLETYPE) sText = "Title Hit";
if(type == IDS_SRG_DISPLAYTYPE) sText = "Display Hit";
if(type == IDS_SRG_LEGENDTYPE) sText = "Legend Hit";
if(type == IDS_SRG_TEXTPANELTYPE) sText = "TPanel Hit";
if(type == IDS_SRG_LABELTYPE) sText = "Label Hit";
if(type == IDS_SRG_LABELBLOCKTYPE) sText = "LabelBlock Hit";