Skip to main content
Email Password   helpLost your password?

Introduction

In VC++ we have a class CRectTracker which helps drawing the trackers and also there is function a DrawFocusRect() with which tracker behavior can be achieved. In C# I did not find any kind of such functionality (if there is then I am unaware at the moment.). So I decided to make program which draw box with tracker and allows manipulation with the box with the help of trackers.

Key features

I tried to avoid Form�s Invalidate() function as it generates flickering effects and drawing is not smooth. I designed the program in a way to maximize the usage of double buffering to avoid flickering effect.

Using the code

Class CRectTracker

Methods Functionality
DrawSelectionGhostRect() Draws the given ghost rectangle on the specified bitmap
InitTrackerRects() Initializes the eight rectangle of the tracker.
DrawSelectionTrackers() Draws the already initialized tracker rectangles
CursorCheck() Checks the position of the cursor and changes the form cursor with appropriate cursor and returns the border of the rectangle for the resizing purpose.

In the main program there are three modes of the program. First is the �None mode� which indicates that user is not drawing, second mode is the �Drawing mode� and it is invoked when user selects the Box icon from the toolbar and third is the �selection mode� it is invoked when user selects a box for changing the positioning or size.  

There is main bitmap which holds the current drawing. Whenever a change is required like drawing rubber band selection or drawing tracker a copy of the main bitmap is made and saved in TrackerImage bitmap and all the changes are made in it and in the end it is assigned to the main bitmap. Even when repaint is required then RePaintForm() function is called instead of calling paint() function of the form to avoid the flickering effect.

Conclusion

A simple program that demonstrates double buffering & tracker drawing is included. OnPaint() generates flickering effects so it is recommended to draw first on the bitmap and then on the form.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralI can't open the demo code. Better code idea? Pin
Member 3390864
7:18 4 Jul '09  
GeneralMy vote of 1 Pin
Mrtnk
1:26 25 Jun '09  
Generaldraw a rectangle on image Pin
Babita Shivade
2:14 29 Apr '09  
Generalhow to add a tracker for a bit map Pin
sandun neelanga
0:09 31 Oct '07  
AnswerRe: how to add a tracker for a bit map Pin
00thilani
7:41 2 Jan '08  
Generalsource code Pin
Raja Sekhar Bandaru
15:31 25 Apr '07  
GeneralRe: source code Pin
khurram7t8
22:27 25 Apr '07  
Questionhow to delete a selected object? Pin
yuxuant
20:28 31 Oct '05  
AnswerRe: how to delete a selected object? Pin
khurram7t8
7:31 5 Nov '05  
Generalthanks! I have a question Pin
xu xiaodong
4:24 7 Jun '04  
GeneralRe: thanks! I have a question Pin
khurram7t8
19:49 8 Jun '04  
GeneralExcellent Pin
cql60
10:06 21 Nov '03  
GeneralRe: Excellent Pin
Nickle
11:19 18 Jan '04  
GeneralThanks Pin
Xboss
21:22 30 Sep '03  
GeneralDrawing a Tracker Pin
Jay Giganti
6:23 12 Sep '03  
Generalthanks Pin
birol.bellikan@kibarholding.com
2:22 27 Jun '03  
GeneralThanks! Pin
Joost Huizinga
4:31 11 Jun '03  
Generalmultiple selection & group move Pin
Dan Colasanti
9:05 6 Jun '03  
Generalcorner resizers & Z-order selection problems Pin
Dan Colasanti
8:58 6 Jun '03  
GeneralRe: corner resizers & Z-order selection problems Pin
khurram_manglian@yahoo.com
17:48 6 Jun '03  
GeneralRe: corner resizers & Z-order selection problems Pin
Nickle
11:18 18 Jan '04  
GeneralAny chance doing this in C++? Pin
WREY
3:28 6 Jun '03  
GeneralRe: Any chance doing this in C++? Pin
SledgeHammer
6:18 6 Jun '03  


Last Updated 5 Jun 2003 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009