I am a novice in C# and OOP. I found that the
TrackRubberBand method of the MFC
CRectTracker class is not available in .NET. So I wrote a simple class
RectTracker in C# and I called it
CRectTrackerCS. I hope it is helpful to you.
To throw out a minnow to catch a whale. If you find problems and bugs in this code, please tell me about it. Thanks!
Using the code
CRectTrackerCS 2.1 is very easy to use.
- Create an instance and initialize it:
CRectTrackerCS TestRubberBand = new CRectTrackerCS();
- On the
- And last, don't forget to free up the resources:
CRectTrackerCS has four attributes (Read Only):
Height. Add a
StatusStrip control, and in the
toolStripStatusLabel1.Text = "RubberBand:"+" X="+
TestRect.X.ToString() + " Y="+TestRect.Y.ToString() +
" Width="+TestRect.Width.ToString() +
StatusStrip control will now show the rubber band's attributes.
Tip: If you want the rubber band streamed in a Form, you need to add a
Timer control and in the
InvalidateRectangle(), which is a new method in CRectTrackerCS 2.1:
CRectTrackerCS 2.1 --- What's new
Three methods have been added:
SetRubberBandStyle (+2 overloads), and
LoadDefaultRubberBandStyle. You can change the style and color of the rubber band and the
Here are the
StyleFlags of CRectTrackerCS 2.1:
All suggestions, ideas, bug reports, and criticisms are welcome!
- WinXP (Professional SP2)
- Microsoft Visual Studio 2005 (Installed edition: C# Express)
- Version 8.0.50727.762 (SP.050727-7600)
- Microsoft .NET Framework Version 2.0.50727
My blog's address: http://timw.yeah.net, http://timw.126.com.
- CRectTrackerCS 2.1 18:17 2007-06-01
- CRectTrackerCS 2.0 17:08 2007-05-31
- CRectTrackerCS 1.0 23:28 2007-05-26