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


[Back] [Next]