Jump to content

WinMapWindowPoints: Difference between revisions

From EDM2
Ak120 (talk | contribs)
Created page with "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,..."
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
This function maps a set of points from a coordinate space relative to one window into a coordinate space relative to another window.
This function maps a set of points from a coordinate space relative to one window into a coordinate space relative to another window.


==Syntax==
== Syntax ==
  WinMapWindowPoints(hwndFrom, hwndTo, prgptl, cwpt)
<pre>
  WinMapWindowPoints(hwndFrom, hwndTo, prgptl, cwpt);
</pre>
 
== 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.
 
== Example Code ==
Declaration:
<pre>
#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);
</pre>
 
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.
<pre>
#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 */
   }
</pre>
 
== Related Functions ==
* [[WinMapDlgPoints]]


[[Category:Win]]
[[Category:Win]]

Latest revision as of 16:01, 15 May 2025

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.

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 */
   }

Related Functions