Home

Cursors

 

A Cursor

 

Introduction

A cursor is a small picture that represents the position of the mouse on a Windows screen. Because Microsoft Windows is a graphic-oriented operating system, when it installs, it creates a set of standard or regularly used icons. These can be seen by opening the Control Panel window and double-clicking the Mouse icon. This opens the Mouse Properties dialog box where you can click the Pointers tab to see a list of standard cursors installed by Windows:

 

Mouse Properties

Microsoft Visual Studio 2005 provides a rich collection of cursors you can easily use in your application. You can apply them to any control as you wish.

To support cursors, the .NET Framework provides two classes. One of the classes used for cursors is called Cursors. This sealed class mostly contains a list of available cursors as properties. Another technique consists of using a cursor not listed in the Properties window. A cursor is based on the Cursor class. Both the Cursors and the Cursor classes are defined in the System.Windows.Forms namespace that is part of the System.Windows.Forms.dll library.

Practical Learning Practical Learning: Introducing Cursors

  1. From the Common Controls section of the Toolbox, click the ListBox control ListBox and click the upper-left section of the form
  2. From the Containers section of the Toolbox, click the Panel control Panel and click the upper-right section of the form
  3. Once again, from the Common Controls section of the Toolbox, click the TreeView control TreeView and click the lower-left section of the form
  4. From the Common Controls section of the Toolbox, click the RichTextBox control RichTextBox and click the lower-right section of the form
     
    Cursor

Creating a Cursor

A cursor is primarily represented in Microsoft Windows as a (resource) file. This means that, to get a cursor, you can design one. Fortunately, Microsoft Windows and the .NET Framework provides many cursors ready to be used. Otherwise, you can create and design your own.

To create a cursor, you can use use Microsoft Visual Studio. To start, on the main menu, you can click Project -> Add New Item... In the Templates list, you can click Cursor File, give it a name, and click Add.

A cursor is a Windows file that has the extension .cur.

Practical Learning Practical Learning: Creating a Cursor

  1. On the main menu, you can click Project -> Add New Item...
  2. In the Templates list, click Cursor File
  3. Change the Filename to push and click Add
  4. On the main menu, click File -> Save push.cur As...
  5. Locate and display the bin sub-folder of your project
  6. Double-click Debug to select that folder
  7. Click Save
  8. On the Image Editor toolbar, click the Line tool Line. In the Colors window, make sure the black color is selected
  9. Draw a vertical line from the pixel on the 6th column and 2nd row from top
  10. Draw a diagonal line at 45˚ from the top border of the new line to the lower-right until the line is at 5 pixels from the right border of the drawing area
     
    Cursor Design
  11. Draw a horizontal line from the lower border of the dialog line to half-left
  12. Draw a diagonal line from the lower border of the vertical line to the left border of the horizontal line:
     
    Cursor Design 2
  13. Draw another diagonal line from the top corner of the current shape to the intersection of horizontal and left diagonal line:
     
    Cursor Design 3
  14. On the Image Editor toolbar, click Fill Fill
  15. In the Colors window, click the button with a pink monitor
  16. In the drawing area, click the right triangle.
  17. In the Colors window, click the white color
  18. On the drawing area, click in the left triangle
     
    Cursor Design 4
  19. Save the file
 

Home Copyright © 2007 FunctionX, Inc. Next