TCursor
Fuente: source/classes/cursor.prg
Standalone class (no inheritance)
TCursor loads, creates, and manages mouse cursor resources. It supports predefined Windows
system cursors, custom cursors from .cur/.ico files, cursors from program resources, and
cursors created programmatically from bitmap images. TCursor is used by the FiveWin framework
for cursor management Funciones like CursorHand(), CursorArrow(), CursorWait(), etc.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
hCursor | Numeric (Handle) | Windows cursor handle |
lPredef | Logical | Whether the cursor is a predefined system cursor (not destroyed on End) |
Source | Character | Source description string (e.g., "PREDEF:HAND" or file path) |
Predefined Cursor Types
| Name | Description |
|---|---|
ARROW | Standard arrow pointer (IDC_ARROW) |
IBEAM | Text I-beam cursor (IDC_IBEAM) |
WAIT | Hourglass/wait cursor (IDC_WAIT) |
CROSS | Crosshair cursor (IDC_CROSS) |
UPARROW | Vertical arrow cursor (IDC_UPARROW) |
SIZE | Four-pointed size/move cursor (IDC_SIZEALL) |
HAND | Hand pointer (clickable link) |
STOP | Stop/no-entry cursor |
DRAG | Drag cursor |
SEARCH | Search/zoom cursor |
SIZENWSE | Diagonal resize NW-SE |
SIZENESW | Diagonal resize NE-SW |
SIZEWE | Horizontal resize (west-east) |
SIZENS | Vertical resize (north-south) |
Methods
| Method | Description |
|---|---|
New( cResOrFile, cPredef ) | Create cursor from a resource name, .cur/.ico file, or predefined type |
NewBmp( oBitmap, nHotRow, nHotCol ) | Create cursor from a TBitmap or TBtnBmp object with hotspot coordinates |
NewFromBitmap( oBitmap, nHotRow, nHotCol, hMaskBitmap ) | Create cursor from a bitmap with a separate mask bitmap |
SetSource( cSource, cPredef ) | Set or change the cursor source and reload the cursor handle |
End() | Release the cursor handle (predefined cursors are not destroyed) |
Example
#include "FiveWin.ch"
function Main()
local oWnd, oCursor
DEFINE WINDOW oWnd TITLE "TCursor Demo" SIZE 400, 300
// Load a hand cursor from a file
oCursor := TCursor():New( "hand.cur" )
// Alternative: predefined hand cursor
// oCursor := TCursor():New( , "HAND" )
oWnd:SetCursor( oCursor:hCursor )
ACTIVATE WINDOW oWnd CENTERED
oCursor:End()
return nil
Notes
- Predefined cursors (ARROW, IBEAM, WAIT, etc.) are loaded from Windows system resources and should not be destroyed. TCursor tracks this via the
lPredefflag and skipsDestroyCursor()for system cursors. - Use
Source(protected) to read back the source description of the currently loaded cursor. - The
NewBmp()method creates a cursor from any TBitmap object, automatically handling palette and transparency. - Cursors from resources (compiled into the .exe) are loaded via
LoadCursor( GetResources(), cResName ).