Knowledge Base |

# How to Turn on Mouse Trails with Visual Basic

Article ID: 110541

Article Last Modified on 12/9/2003

APPLIES TO

- Microsoft Visual Basic 2.0 Standard Edition
- Microsoft Visual Basic 3.0 Professional Edition
- Microsoft Visual Basic 2.0 Professional Edition
- Microsoft Visual Basic 3.0 Professional Edition

This article was previously published under Q110541

## SUMMARY

This article demonstrates how to turn on mouse trails by using the Escape() Windows API function. This works on computers that have video drivers that support mouse trails -- not all video drivers do. The Escape() function returns a zero if the function is not supported by the video driver.

## MORE INFORMATION

### Step by Step to an Application That Turns on Mouse Trails

1. Start Visual Basic, or if Visual Basic is already running, choose New Project from the File menu (ALT, F, N). Form1 is created by default.
2. Add a Command Button (Command1) to Form1.
3. Add the following code to the General Declarations section of Form1:

          ' Enter the following Declare statement on one, single line:
          Declare Function Escape Lib "GDI" (ByVal hDC As Integer,
             ByVal nEscape As Integer, ByVal nCount As Integer, lpInData As Any,
             lpOutData As Any) As Integer

          Const MouseTrails = 39
          Const SizeOfWord = 2

4. Add the following code to the Command1_Click event of Form1:

          Dim x As Integer

          x = 7  ' Set x to one of the following values:
                 ' 1 to 7 : turns mouse trails on and shows 1 to 7 trailers
                 '      0 : turns off mouse trails
                 '     -1 : turns mouse trails on, reads info from WIN.INI
                 '     -2 : disables mouse trails, doesn't update WIN.INI
                 '     -3 : enables mouse trails, updates WIN.INI

          result% = Escape(form1.hDC, MouseTrails, SizeOfWord, x, 0&)

5. Run the program. Click the Command1 button to turn on mouse trails.

For more information about the Escape() Windows API function and mouse trails, please see Windows version 3.1 SDK help file that ships with the Professional Edition of Visual Basic.

Additional query words: 2.00 3.00

Keywords: KB110541