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
- Start a new project in Visual Basic. Form1 is created by default.
- Place a picture box and command button on Form1.
- 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")
- 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
- Start App Studio Version 1.5. On the File menu, click New.
- In the New dialog box, select Resource File from the list of types, and
click OK.
- On the Resource menu in App Studio, click Import. In the Import Resource
dialog box, select Cursors (*.Cur) from the Types of Files list.
- 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.
- By default, the ID of the resource will be 101. The ID is displayed in
the Resource File dialog box.
- On the File menu, click Save As, and save the file as Vbres.res. Exit
App Studio.
- Start a new project in the 16-bit edition of Visual Basic. Form1 is
created by default.
- 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.
- 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
- Run the example by pressing the F5 key. The picture box displays a
black and white picture.
|