PRB: Visual Basic 4.0 Does Not Support Color Cursor Files

Last reviewed: November 17, 1995
Article ID: Q138529
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 16-bit and 32-bit, for Windows, version 4.0

SYMPTOMS

If cursor files are displayed in a picture box or as a mouse icon, then the picture shows in black and white only. Colors are not displayed.

RESOLUTION

Use icon files instead of cursor files. Many existing icons can be found in the Vb\Icons directory. In addition, new color icons can be created by using the IconWorks application found in the Vb\Hc directory.

STATUS

This behavior is by design. Support for color cursor files was not built into Visual Basic 4.0.

MORE INFORMATION

Regardless of the method used to display a cursor file (using the LoadPicture command or the LoadResPicture command and a resource file), cursor files will always be displayed in black and white.

Step-by-Step Example - Loading a Cursor Using LoadPicture Command

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Place a picture box and command button on Form1.

  3. In the Click event for the command button, place the following line of code (assuming you have the standard cursors installed in the standard directories):

       ' On Windows NT use:
       Picture1.Picture = LoadPicture("c:\windows\system32\3dgarro.cur")
    
       ' On Windows 95 use:
       Picture1.Picture = LoadPicture("c:\windows\system\arrow_5.cur")
    
    

  4. Run the example by pressing the F5 key. The arrow pointer is displayed as a black color in the picture box. When this cursor file is viewed in a Resource Editor the arrow has a golden color.

The next example uses App Studio which ships with Visual C++ Version 1.5 to create a resource file. It then adds the file to a project created in 16-bit Visual Basic 4.0. The results are the same.

Step-by-Step Example - Loading a Cursor File by Using a Resource File

  1. Start App Studio Version 1.5. On the File menu, click New.

  2. In the New dialog box, select Resource File from the list of types, and click OK.

  3. On the Resource menu in App Studio, click Import. In the Import Resource dialog box, select Cursors (*.Cur) from the Types of Files list.

  4. Select any color cursor file from list of files. On a computer running Windows NT there are some cursor files in the Windows\System32 directory. On Windows 95, you'll find them in the Windows\Cursors directory.

  5. By default, the ID of the resource will be 101. The ID is displayed in the Resource File dialog box.

  6. On the File menu, click Save As, and save the file as Vbres.res. Exit App Studio.

  7. Start a new project in the 16-bit edition of Visual Basic. Form1 is created by default.

  8. Add the resource file to the project. On the File menu, click Add File. In the Add File dialog box, select Resource Files (*.res) from the Types of Files combo box. Then select Vbres.res from the list of files.

  9. Add a picture box (Picture1) and a command button (Command1) to Form1. Add the following code to the Click event for Command1:

       Private Sub Command1_Click ()
          Const vbResCursor = 2
          Picture1.Picture = LoadResPicture(101, vbResCursor)
       End Sub
    
    

  10. Run the example by pressing the F5 key. The picture box displays a

        black and white picture.
    


Additional reference words: 4.00 picture box icon vb4win vb4all
KBCategory: kbenv kbprb
KBSubcategory: PrgCtrlsStd


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.