Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1448

[VB6] clsCursor - Setting the IDC_HAND & Other Cursors Properly

$
0
0
Most solutions that addresses the MousePointer property's lack of support for some of the standard cursors (most notably the "hand" cursor) tend to be based on either converting the standard cursor to a MouseIcon/DragIcon or setting the cursor using the SetCursor API function during the MouseMove event. While both approaches produce generally acceptable results most of the time, they still have obvious shortcomings that makes them appear like cheap workarounds. Converting a standard cursor to a MouseIcon/DragIcon, for instance, doesn't support animated cursors. Setting the cursor during the MouseMove event, on the other hand, exhibits an annoying flickering as the cursor rapidly alternates between the class cursor and the specified cursor. The proper way of dealing with this, according to MSDN, is through subclassing:

Quote:

Originally Posted by MSDN
The Window Class Cursor

When you register a window class, using the RegisterClass function, you can assign it a default cursor, known as the class cursor. After the application registers the window class, each window of that class has the specified class cursor.

To override the class cursor, process the WM_SETCURSOR message. You can also replace a class cursor by using the SetClassLong function. This function changes the default window settings for all windows of a specified class. For more information, see Class Cursor.

The small and simple class module (and supporting standard module) in the attachment below contains all of the logic needed to set the desired standard cursor for all of the specified windowed and/or windowless controls. A demo project is also included that illustrates its use.


Name:  clsCursor Demo.png
Views: 96
Size:  5.8 KB


Subclassing, of course, has its disadvantages as well, especially when debugging in the IDE. However, for those seeking more professional looking results, there's no better way of overriding the class cursor than via subclassing.
Attached Images
 
Attached Files

Viewing all articles
Browse latest Browse all 1448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>