Jump to content

WinQueryPointerPos

From EDM2
Revision as of 01:44, 9 April 2025 by Martini (talk | contribs) (Created page with "This function returns the pointer position. ==Syntax== WinQueryPointerPos(hwndDeskTop, pptlPoint) ==Parameters== ;hwndDeskTop (HWND) - Input: Desktop-window handle. :;HWND_DESKTOP:: The desktop-window handle. :;Other:: Specified desktop-window handle. ;pptlPoint (PPOINTL) - Output: Pointer position in screen coordinates. ==Returns== ;rc (BOOL) - Returns: Pointer position returned indicator. :;TRUE: Successful completion. :;FALSE: Error occurred. ==Remarks==...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function returns the pointer position.

Syntax

WinQueryPointerPos(hwndDeskTop, pptlPoint)

Parameters

hwndDeskTop (HWND) - Input
Desktop-window handle.
HWND_DESKTOP
: The desktop-window handle.
Other
: Specified desktop-window handle.
pptlPoint (PPOINTL) - Output
Pointer position in screen coordinates.

Returns

rc (BOOL) - Returns
Pointer position returned indicator.
TRUE
Successful completion.
FALSE
Error occurred.

Remarks

The WinQueryMsgPos is used to get the pointer position of the last message obtained by means of the WinGetMsg or WinPeekMsg functions.

Errors

Possible returns from WinGetLastError:

PMERR_INVALID_HWND (0x1001)
An invalid window handle was specified.

Example Code

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

HWND      hwndDeskTop; /* Desktop-window handle. */
PPOINTL   pptlPoint;   /* Pointer position in screen coordinates. */
BOOL      rc;          /* Pointer position returned indicator. */

rc = WinQueryPointerPos(hwndDeskTop, pptlPoint);

This example displays the pointer position.

#define INCL_WINWINDOWMGR
#define INCL_WINPOINTERS
#include <OS2.H>

HWND   hwndClient;
CHAR   szMsg[100];
POINTL ptl;

 WinQueryPointerPos(HWND_DESKTOP, &ptl);
 sprintf(szMsg, "x = %ld  y = %ld", ptl.x, ptl.y);
 WinMessageBox(HWND_DESKTOP,
               hwndClient,               /* client-window handle  */
               szMsg,                    /* body of the message   */
               "Debugging information",   /* title of the message  */
               0,                        /* message box id        */
               MB_NOICON | MB_OK); /* icon and button flags */

Related Functions