1. Base concept and principle on how to use CRectTracker:
Allows an item to be displayed, moved, and resized in different fashions.
--Form MSDN
Example to use this (when you drag the mouse, the RectTracker comes):
1) QQ Snap Desktop picture;
2) Windows explorer;
....
2. Important member funtions of CRectTracker:
SetRect // set the rect of rect tracker
Track // change the position of rect tracker
SetCursor // Change the cursor
HitTest
Draw // draw the rect tracker
Refer MSDN for the Detail.
3. Take an example to show how to use the CRectTracker.
Implement goal show as the follow picture:
Environment VS 2008 Windows XP EN
1) start a MFC dialog based project named tracker
2) Add three member:
CRectTracker m_tracker; // CRectTracker object
CPoint m_start; // the the mouse down, record the start point here
BOOL m_bDraw; // whether draw
3) Add a WM_LBUTTONDOWN handle function(OnLButtonDown)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/1327ab569c1ae82736693a50b8e33378.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/7ff8d92cded7e0ce15e7ca1acc870052.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/717446ca04a6125dc5b6b54e0fa14ab4.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)