Jump to content

WinLoadPointer

From EDM2
Revision as of 03:21, 9 April 2025 by Martini (talk | contribs) (Created page with "This function ''loads a pointer from a resource file into the system''. ==Syntax== WinLoadPointer(hwndDeskTop, Resource, idPointer) ==Parameters== ;hwndDeskTop (HWND) - Input : Desktop-window handle. :;HWND_DESKTOP :: The desktop window :;Other :: Desktop-window handle returned by WinQueryDesktopWindow. ;Resource (HMODULE) - Input : Resource identity containing the pointer definition. :;NULLHANDLE :: Use the resources file for the application. :;Other :: M...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function loads a pointer from a resource file into the system.

Syntax

WinLoadPointer(hwndDeskTop, Resource, idPointer)

Parameters

hwndDeskTop (HWND) - Input
Desktop-window handle.
HWND_DESKTOP
The desktop window
Other
Desktop-window handle returned by WinQueryDesktopWindow.
Resource (HMODULE) - Input
Resource identity containing the pointer definition.
NULLHANDLE
Use the resources file for the application.
Other
Module handle returned by the DosLoadModule or DosQueryModuleHandle call referencing a dynamic-link library containing the resource.
idPointer (ULONG) - Input
Identifier of the pointer to be loaded.
It must be greater or equal to 0 and less or equal to 0xFFFF.

Returns

hptr (HPOINTER) - returns
Pointer handle.
NULLHANDLE
Error has occurred
Other
Handle of loaded pointer.

Remarks

A new copy of the pointer is created each time this function is called. The pointer created by this function can be destroyed using the WinDestroyPointer function. To get one of the standard system pointers, use the WinQuerySysPointer function. The pointer is owned by the process from which this function is issued. It cannot be accessed directly from any other process. If it still exists when the process terminates, it is automatically deleted by the system.

Errors

Possible returns from WinGetLastError:

PMERR_INVALID_HWND (0x1001)
An invalid window handle was specified.
PMERR_RESOURCE_NOT_FOUND (0x100A)
The specified resource identity could not be found.

Example Code

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

HWND     hwndDeskTop;  /*  Desktop-window handle. */
HMODULE  Resource;     /*  Resource identity containing the pointer definition. */
ULONG    idPointer;    /*  Identifier of the pointer to be loaded. */
HPOINTER hptr;         /*  Pointer handle. */

hptr = WinLoadPointer(hwndDeskTop, Resource, idPointer);

This example calls WinLoadPointer to load an application-defined pointer. When processing the WM_MOUSEMOVE message, the loaded pointer is displayed by calling WinSetPointer.

#define INCL_WINPOINTERS        /* Window Pointer Functions     */
#include <os2.h>

HPOINTER  hptrCrossHair;/* pointer handle                       */

case WM_CREATE:
    hptrCrossHair = WinLoadPointer(HWND_DESKTOP,
        0L,                /* load from .exe file    */
        IDP_CROSSHAIR);    /* identifies the pointer */

case WM_MOUSEMOVE:
    WinSetPointer(HWND_DESKTOP, hptrCrossHair);

Related Functions