Jump to content

WinDrawPointer

From EDM2
Revision as of 01:46, 9 April 2025 by Martini (talk | contribs) (Returns)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function draws a pointer in the passed hps at the passed coordinates [lx, ly].

Syntax

WinDrawPointer(hps, lx, ly, hptrPointer, ulHalftone)

Parameters

hps (HPS) - Input
Presentation-space handle into which the pointer is drawn.
This can be either a micro presentation space or a normal presentation space (see `GpiCreatePS` in the Graphics Programming Interface Programming Reference).
lx (LONG) - Input
x-coordinate at which to draw the pointer, in device coordinates.
ly (LONG) - Input
y-coordinate at which to draw the pointer, in device coordinates.
hptrPointer (HPOINTER) - Input
Pointer handle.
The pointer should be loaded using WinLoadPointer, WinCreatePointer, or WinCreatePointerIndirect.
ulHalftone (ULONG) - Input
Shading control with which to draw the pointer.
DP_NORMAL:: As it normally appears.
DP_HALFTONED:: With a halftone pattern where black normally appears.
DP_INVERTED:: Inverted, black for white and white for black.
DP_MINIICON:: Bit map of a mini icon.

Returns

rc (BOOL) - Returns
Success indicator.
TRUE
Successful completion.
FALSE
Function failed.

Remarks

This function should only be used in draw mode (DM_DRAW) to a screen device context.

Errors

Possible returns from WinGetLastError:

PMERR_INVALID_HPTR (0x101B)
An invalid pointer handle was specified.
PMERR_INVALID_FLAG (0x1019)
An invalid bit was set for a parameter. Use constants defined by PM for options, and do not set any reserved bits.

Example Code

#define INCL_WINPOINTERS /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HPS       hps;         /* Presentation-space handle into which the pointer is drawn. */
LONG      lx;          /* x-coordinate at which to draw the pointer, in device coordinates. */
LONG      ly;          /* y-coordinate at which to draw the pointer, in device coordinates. */
HPOINTER  hptrPointer; /* Pointer handle. */
ULONG     ulHalftone;  /* Shading control with which to draw the pointer. */
BOOL      rc;          /* Success indicator. */

rc = WinDrawPointer(hps, lx, ly, hptrPointer,
                    ulHalftone);

This example draws a bit map pointer, created by either WinCreatePointer or WinCreatePointerIndirect, in response to a paint message (WM_PAINT).

#define INCL_WINPOINTERS       /* Window Pointer Functions     */
#define INCL_GPIBITMAPS        /* Graphics bit-map functions   */
#include <os2.h>

HPS   hps;          /* presentation-space handle         */
HWND  hwnd;         /* window handle                     */
HPOINTER  hptr;       /* bit-map pointer handle            */
HBITMAP  hbm;        /* bit-map handle                    */
BOOL  fSuccess;     /* success indicator                 */
ULONG   ulHalftone=DP_NORMAL; /* draw with normal shading      */

case WM_CREATE:
   hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
   hbm = GpiLoadBitmap(hps, 0L, IDP_BITMAP, 64L, 64L);
   WinEndPaint(hps);

   hptr = WinCreatePointer(HWND_DESKTOP, hbm,
                           TRUE, /* use true (system) pointer */
                           0, 0); /* hot spot offset (0,0)     */

case WM_PAINT:
   hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
   fSuccess = WinDrawPointer(hps, 50, 50, hptr, ulHalftone);
   WinEndPaint(hps);

Related Functions