Jump to content

WinMapWindowPoints

From EDM2
Revision as of 15:59, 15 May 2025 by Martini (talk | contribs)

This function maps a set of points from a coordinate space relative to one window into a coordinate space relative to another window.

Syntax

 WinMapWindowPoints(hwndFrom, hwndTo, prgptl, cwpt);

Parameters

hwndFrom (HWND) - input
Handle of the window from whose coordinates points are to be mapped.
HWND_DESKTOP: Points are mapped from screen coordinates.
Other: Points are mapped from window coordinates.
hwndTo (HWND) - input
Handle of the window to whose coordinates points are to be mapped.
HWND_DESKTOP: Points are mapped into screen coordinates.
Other: Points are mapped into window coordinates.
prgptl (PPOINTL) - in/out
Points to be mapped to the new coordinate system.
cwpt (LONG) - input
Number of points to be mapped.
prgptl can be a RECTL structure, in which case this parameter should have the value 2.
Note
This is not supported in all languages.

Returns

rc (BOOL) - returns
Success indicator.
TRUE: Successful completion.
FALSE: Error occurred.

Errors

Possible returns from WinGetLastError

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

Related Functions

Example Code

Declaration:

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

HWND       hwndFrom;    /*  Handle of the window from whose coordinates points are to be mapped. */
HWND       hwndTo;      /*  Handle of the window to whose coordinates points are to be mapped. */
PPOINTL    prgptl;      /*  Points to be mapped to the new coordinate system. */
LONG       cwpt;        /*  Number of points to be mapped. */
BOOL       rc;          /*  Success indicator. */

rc = WinMapWindowPoints(hwndFrom, hwndTo,
           prgptl, cwpt);

This example calls WinMapWindowPoints to map a mouse point on the desktop window to a mouse point in the client window and then checks whether the mouse pointer is inside the client area or not.

#define INCL_WINWINDOWMGR       /* Window Manager Functions     */
#define INCL_WINRECTANGLES      /* Window Rectangle Functions   */
#define INCL_WINPOINTERS        /* Window Pointer Functions     */
#include <os2.h>

HAB     hab;            /* anchor-block handle                  */
HWND  hwndClient;       /* handle of client window              */
BOOL  fSuccess;         /* success indicator                    */
POINTL ptlMouse;        /* mouse pointer position               */
RECTL rclWork;          /* client area                          */

/* get current mouse pointer position */
WinQueryPointerPos(HWND_DESKTOP, &ptlMouse);

/* map from desktop to client window */
fSuccess = WinMapWindowPoints(HWND_DESKTOP, hwndClient,
                              &ptlMouse, 1);

/* check if new mouse position is inside the client area */
WinQueryWindowRect(hwndClient, &rclWork);
if (WinPtInRect(hab, &rclWork, &ptlMouse))
   {
   /* pointer is in client area */
   }