Drawing a Line on an Image using the "Rubber-Banding" Technique.

This demo is available in two versions: one for use with Visual Basic 5 or 6, the other for use with Visual Basic.NET. The appropriate version can be downloaded from the links below.

Visual Basic.NET

To run this demo you need the csXImage trial ocx control installed on your system as well as MS Visual Studio.NET. The trial control and the example files are available below:

Download the trial csXImage control - csXImageTrial.exe (1.8 MB)

The demo VB.NET project - DrawLineDemoVBNET.zip (65 KB)

Visual Basic 5 or 6

To run this demo you need the csXImage trial ocx control installed on your system as well as MS Visual Basic 5 or 6. The trial control and the example files are available below:

Download the trial csXImage control - csXImageTrial.exe (1.8 MB)

The demo VB project - DrawLineDemo.zip (4 KB)

A common use of an imaging component like csXImage is to enable the user to draw on an image using the mouse. This simple VB project shows the use of the mouse events of csXImage for this purpose. It demonstrates the "rubber-banding" method by which the user is able to first fix one end of a line, then move the mouse around, with the line following the movements, before selecting the end point.

When the VB project is run, a form is displayed with an empty, white image. When the Draw Line button is clicked, the user can then click the mouse on the image to start drawing a line. As long as the mouse buttom remains down, the mouse can be moved around the image and a line will always join the start point to the current mouse position, like a stretching rubber band. When the mouse button is released, the drawing of the line is completed.

Description of the project.

The image below is a screenshot from this demo.

Visual Basic example of drawing a line with rubber banding