Jump to content

WinCreatePointerIndirect

From EDM2
Revision as of 15:02, 16 May 2023 by Ak120 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function creates a colored pointer or icon from a bit map.

Syntax

WinCreatePointerIndirect(hwndDesktop, pptri)

Parameters

hwndDesktop (HWND) - input
Desktop-window handle or HWND_DESKTOP.
pptri (PPOINTERINFO) - input
Pointer information structure.
The fields in this structure must be set before the call is made:
fPointer is set to TRUE if a pointer is being created, or to FALSE if an icon is being created.
xHotSpot yHotSpot are set to the relative position in the icon or pointer that is associated with the mouse position.
hbmPointer is a bit map that specifies the AND and XOR masks, as used for black and white pointers and icons.
hbmColor is a color bit map that describes the color content of the pointer or icon.
It is an error if hbmPointer is NULLHANDLE. Also, the width of hbmPointer must be the same as that of hbmColor and the height of hbmPointer must be double that of hbmColor (to allow for both the AND and the XOR mask).

Returns

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

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 WinCreatePointer).

This function makes copies of the supplied bit maps.

Example Code

This example creates a colored pointer from a bit map during the creation of the window (WM_CREATE). The pointer bit map (id IDP_BITMAPPTR in the EXE) and color bit map (id IDP_BITMAPCLR in the EXE file) are 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  hbmPointer;    /* bit-map handle (AND/XOR)             */
HBITMAP  hbmColor;      /* bit-map handle (color)               */
POINTERINFO  pptriPointerInfo; /* pointer info structure        */

case WM_CREATE:
     hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
     /* load pointer bit map */
     hbmPointer = GpiLoadBitmap(hps, NULLHANDLE, IDP_BITMAPPTR, 64L, 128L);
     /* load color bit map */
     hbmColor = GpiLoadBitmap(hps, NULLHANDLE, IDP_BITMAPCLR, 64L, 64L);
     WinEndPaint(hps);

     /* initialize POINTERINFO structure */
     pptriPointerInfo.fPointer = TRUE;  /* creating pointer */
     pptriPointerInfo.xHotspot = 0; /* x coordinate of hotspot */
     pptriPointerInfo.yHotspot = 0; /* y coordinate of hotspot */
     pptriPointerInfo.hbmPointer = hbmPointer;
     pptriPointerInfo.hbmColor = hbmColor;

     hptr = WinCreatePointerIndirect(HWND_DESKTOP,
                                     &pptriPointerInfo);

Definition

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

HWND            hwndDesktop;  /*  Desktop-window handle or HWND_DESKTOP. */
PPOINTERINFO    pptri;        /*  Pointer information structure. */
HPOINTER        hptr;         /*  Pointer handle. */

hptr = WinCreatePointerIndirect(hwndDesktop, pptri);

Related Functions

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