ClassCursorHelper
Provides utility methods for creating and managing custom cursors with DPI scaling support.
Definition
Namespace:Telerik.WinControls
Assembly:Telerik.WinControls.dll
Syntax:
public static class CursorHelper
Inheritance: objectCursorHelper
Properties
FlippedArrowCursor
Gets a flipped arrow cursor optimized for 96 DPI (standard resolution).
Declaration
public static Cursor FlippedArrowCursor { get; }
Property Value
A Cursor representing a flipped arrow cursor at standard 96 DPI resolution.
Remarks
This property provides quick access to a flipped arrow cursor designed for standard DPI settings. The cursor is ideal for indicating reverse or opposite directional operations in the user interface.
For high-DPI scenarios, use GetScaledFlippedArrowCursor(SizeF) instead to ensure proper scaling.
Methods
CursorFromBitmap(Bitmap, Point)
Creates a custom cursor from a bitmap image with the specified hot spot.
Declaration
public static Cursor CursorFromBitmap(Bitmap bitmap, Point hotSpot)
Parameters
bitmap
The bitmap image to use as the cursor appearance.
hotSpot
The point within the bitmap that represents the cursor's active point.
Returns
A new Cursor instance created from the bitmap with the specified hot spot.
Remarks
This method converts a bitmap image into a Windows cursor by:
- Converting the bitmap to an icon handle using GetHicon
- Retrieving and modifying the icon information
- Setting the custom hot spot coordinates
- Creating the final cursor using CreateIconIndirect
The hot spot determines which pixel of the cursor image corresponds to the precise mouse position. For example, an arrow cursor typically has its hot spot at the tip of the arrow.
The caller is responsible for disposing of the returned cursor when it's no longer needed.
GetScaledFlippedArrowCursor(SizeF)
Gets a flipped arrow cursor scaled to the specified DPI scaling factor.
Declaration
public static Cursor GetScaledFlippedArrowCursor(SizeF scaling)
Parameters
scaling
The scaling factor to apply to the cursor (e.g., 1.5 for 150% DPI scaling).
Returns
A Cursor representing a flipped arrow cursor scaled for the specified DPI.
Remarks
This method provides DPI-aware flipped arrow cursors by:
- Loading the cursor from an embedded SVG resource for scalable rendering
- Caching cursors for each unique scaling factor to improve performance
- Calculating the appropriate size and hot spot based on the scaling factor
- Generating a bitmap at the target resolution for crisp appearance
The cursor uses SVG-based rendering to ensure sharp, clean appearance at any DPI setting. The hot spot is automatically scaled to maintain proper cursor behavior across different resolutions.
Cursors are cached per scaling factor, so subsequent calls with the same scaling value return the cached cursor for optimal performance.