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(); r.InflateRect(5,5); if(r.PtInRect(point)) { 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"; AfxMessageBox(sText); } } } |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.