Introduction
We want to find out what controls are in Rectangle1 and Rectangle2 .
Here are some buttons and two rectangles. "Rectangle1
" contains "Button1
","Button2
","Button5
". "Rectangle2
" contains "Button3
","Button4
","Button5
".
If we want find out what controls are contained by Rectangle1 , then
Click "Test Rectangle1
" can show or hide the controls in "Rectangle1
".
If we want find out what controls are contained by Rectangle2 , then
Click "Test Rectangle2
" can show or hide the controls in "Rectangle2
".
Using the Code
The class description is as follows:
template <class DATATYPE,class KEYTYPE,int NUMDIMS,
class KEYTYPEREAL=ELEMTYPE,int TMAXNODES=8,int TMINNODES=TMAXNODES/2> class RTreeEx;
The usage is as follows:
RT::RTreeEx<CWnd *, LONG, 2> m_rt;
LONG lMin[2], lMax[2];
CRect rc;
pCtrl->GetWindowRect(&rc);
ScreenToClient(&rc);
lMin[0] = rc.left;
lMin[1] = rc.top;
lMax[0] = rc.right;
lMax[1] = rc.bottom;
m_rt.Insert(lMin, lMax, pCtrl);
LONG lMin[2], lMax[2];
CRect rc;
lMin[0] = ...;
lMin[1] = ...;
lMax[0] = ...;
lMax[1] = ...;std::set<CWnd *> setCtrl;
m_rt.Search(lMin, lMax, setCtrl);