WinCreatePointer: Difference between revisions
Appearance
Created page with "This function creates a pointer from a bit map. ==Syntax== WinCreatePointer(hwndDesktop, hbmPointer, fPointer, xHotspot, yHotspot); ==Parameters== ; hwndDesktop (HWND) - i..." |
mNo edit summary |
||
Line 1: | Line 1: | ||
This function creates a pointer from a bit map. | This function creates a pointer from a bit map. | ||
==Syntax== | ==Syntax== | ||
WinCreatePointer(hwndDesktop, hbmPointer, fPointer, xHotspot, yHotspot) | WinCreatePointer(hwndDesktop, hbmPointer, fPointer, xHotspot, yHotspot) | ||
==Parameters== | ==Parameters== | ||
; hwndDesktop (HWND) - input | ;hwndDesktop (HWND) - input:Desktop-window handle or HWND_DESKTOP. | ||
:Desktop-window handle or HWND_DESKTOP. | ;hbmPointer (HBITMAP) - input:Bit-map handle from which the pointer image is created. | ||
; 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. | :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 | :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. | |||
; fPointer (BOOL) - input | :;TRUE:The bit map should be stretched (if necessary) to the system pointer dimensions. | ||
:Pointer-size indicator. | :;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). | |||
:;TRUE | ;yHotspot (LONG) - input:y-offset of hot spot within pointer from its lower left corner (in pels). | ||
:;FALSE | |||
; 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== | ==Returns== | ||
; hptr (HPOINTER) - returns | ;hptr (HPOINTER) - returns:Pointer handle. | ||
:Pointer handle. | :;NULLHANDLE:Error | ||
:;Other:Handle of the newly created pointer. | |||
:;NULLHANDLE | |||
:;Other | |||
==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== | ||
Line 51: | Line 31: | ||
See also WinCreatePointerIndirect. | See also WinCreatePointerIndirect. | ||
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 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. | 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. | ||
<pre> | <pre> | ||
#define INCL_WINPOINTERS /* Window Pointer Functions */ | #define INCL_WINPOINTERS /* Window Pointer Functions */ | ||
Line 104: | Line 84: | ||
* WinSetPointerPos | * WinSetPointerPos | ||
* WinSetSysPointerData | * WinSetSysPointerData | ||
* WinShowPointer | * WinShowPointer | ||
[[Category:Win]] | [[Category:Win]] |
Latest revision as of 15:05, 16 May 2023
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