Jump to content

WinCreatePointer

From EDM2

This function creates a pointer from a bit map.

Syntax

WinCreatePointer(hwndDesktop, hbmPointer, fPointer, xHotspot, yHotspot)

Parameters

hwndDesktop (HWND) - input
Desktop-window handle or HWND_DESKTOP.
hbmPointer (HBITMAP) - input
Bit-map handle from which the pointer image is created.
The bit map must be logically divided into two sections vertically, each half representing one of the two images used as the successive drawing masks for the pointer.
For an icon, there are two bit map images. The first half is used for the AND mask and the second half is used for the XOR mask. For details of bit map formats, see
fPointer (BOOL) - input
Pointer-size indicator.
TRUE
The bit map should be stretched (if necessary) to the system pointer dimensions.
FALSE
The bit map should be stretched (if necessary) to the system icon dimensions.
xHotspot (LONG) - input
x-offset of hot spot within pointer from its lower left corner (in pels).
yHotspot (LONG) - input
y-offset of hot spot within pointer from its lower left corner (in pels).

Returns

hptr (HPOINTER) - returns
Pointer handle.
NULLHANDLE
Error
Other
Handle of the newly created pointer.

Errors

Possible returns from WinGetLastError

PMERR_INVALID_HWND (0x1001)
An invalid window handle was specified.
PMERR_HBITMAP_BUSY (0x2032)
An internal bit map busy error was detected. The bit map was locked by one thread during an attempt to access it from another thread.

Remarks

A pointer can be created either as a true pointer (at pointer size), or as an icon pointer (at icon size). The latter is useful when using icons as direct-manipulation objects that the user can "pick up" and move about the screen as a means of performing some operation.

See also WinCreatePointerIndirect.

This function makes copies of the supplied bit maps.

Example Code

This example creates a pointer from a bit map during the creation of the window (WM_CREATE). The bit map (id IDP_BITMAP in the EXE file) is loaded via GpiLoadBitmap.

#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                       */

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)    */

Definition

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

HWND        hwndDesktop;  /*  Desktop-window handle or HWND_DESKTOP. */
HBITMAP     hbmPointer;   /*  Bit-map handle from which the pointer image is created. */
BOOL        fPointer;     /*  Pointer-size indicator. */
LONG        xHotspot;     /*  x-offset of hot spot within pointer from its lower left corner (in pels). */
LONG        yHotspot;     /*  y-offset of hot spot within pointer from its lower left corner (in pels). */
HPOINTER    hptr;         /*  Pointer handle. */

hptr = WinCreatePointer(hwndDesktop, hbmPointer,
         fPointer, xHotspot, yHotspot);

Related Functions

  • WinCreatePointerIndirect
  • WinDestroyPointer
  • WinDrawPointer
  • WinLoadPointer
  • WinQueryPointer
  • WinQueryPointerInfo
  • WinQueryPointerPos
  • WinQuerySysPointer
  • WinQuerySysPointerData
  • WinSetPointer
  • WinSetPointerPos
  • WinSetSysPointerData
  • WinShowPointer