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

DATATypeDescription
hCursorNumeric (Handle)Windows cursor handle
lPredefLogicalWhether the cursor is a predefined system cursor (not destroyed on End)
SourceCharacterSource description string (e.g., "PREDEF:HAND" or file path)

Predefined Cursor Types

NameDescription
ARROWStandard arrow pointer (IDC_ARROW)
IBEAMText I-beam cursor (IDC_IBEAM)
WAITHourglass/wait cursor (IDC_WAIT)
CROSSCrosshair cursor (IDC_CROSS)
UPARROWVertical arrow cursor (IDC_UPARROW)
SIZEFour-pointed size/move cursor (IDC_SIZEALL)
HANDHand pointer (clickable link)
STOPStop/no-entry cursor
DRAGDrag cursor
SEARCHSearch/zoom cursor
SIZENWSEDiagonal resize NW-SE
SIZENESWDiagonal resize NE-SW
SIZEWEHorizontal resize (west-east)
SIZENSVertical resize (north-south)

Methods

MethodDescription
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

Ver También