Jump to content

WinCreatePointerIndirect: Difference between revisions

From EDM2
Created page with "This function creates a colored pointer or icon from a bit map. ==Syntax== WinCreatePointerIndirect(hwndDesktop, pptri) ==Parameters== ; hwndDesktop (HWND) - input : Deskt..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
This function creates a colored pointer or icon from a bit map.  
This function creates a colored pointer or icon from a bit map.


==Syntax==
==Syntax==
Line 5: Line 5:


==Parameters==
==Parameters==
; hwndDesktop (HWND) - input
;hwndDesktop (HWND) - input: Desktop-window handle or HWND_DESKTOP.
: Desktop-window handle or HWND_DESKTOP.  
;pptri (PPOINTERINFO) - input:Pointer information structure.
 
;pptri (PPOINTERINFO) - input
:Pointer information structure.
:The fields in this structure must be set before the call is made:
: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.
::'''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.
::'''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.
::'''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.  
::'''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).
: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==
==Returns==
; hptr (HPOINTER) - returns
; hptr (HPOINTER) - returns: Pointer handle.
: Pointer handle.
:;NULLHANDLE: Error
:;NULLHANDLE
:;Other: Handle of the newly created pointer or icon.
:: Error  
:;Other
:: Handle of the newly created pointer or icon.


==Errors==
==Errors==
Possible returns from WinGetLastError
Possible returns from WinGetLastError
;PMERR_INVALID_HWND (0x1001)
;PMERR_INVALID_HWND (0x1001):An invalid window handle was specified.
: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.
;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==
==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).
  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.  
This function makes copies of the supplied bit maps.


==Example Code==
==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.  
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.
<pre>
<pre>
#define INCL_WINPOINTERS        /* Window Pointer Functions    */
#define INCL_WINPOINTERS        /* Window Pointer Functions    */
Line 97: Line 88:
* WinSetPointerPos
* WinSetPointerPos
* WinSetSysPointerData
* WinSetSysPointerData
* WinShowPointer  
* WinShowPointer
 
[[Category:Win]]
[[Category:Win]]

Latest revision as of 15:02, 16 May 2023

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