This example processes a WM_BUTTON1UP message, converts the mouse pointer coordinates into a POINTL structure, and calls WinPtInRect to determine if the mouse was clicked in the predefined global rectangle.

#define INCL_WIN
#define INCL_WINRECTANGLES
#include <OS2.H>

HAB hab;          /* anchor-block handle */
/* . */
/* . */
RECTL rclGlobal;
POINTL ptl;
HPS hps;

USHORT msg;
MPARAM mp1;

/* inside client window function. */

switch(msg)
{
 case WM_COMMAND:
 /* The user has chosen a menu item.  Process the selection */
 /* accordingly.                                            */

  switch ( SHORT1FROMMP( mp1 ) )
  {

   case WM_BUTTON1UP:
     ptl.x = (LONG) SHORT1FROMMP(mp1);
     ptl.y = (LONG) SHORT2FROMMP(mp1);
        WinPtInRect(hab,   /* anchor-block handle      */
         &rclGlobal,       /* address of the rectangle */
         &ptl);            /* address of the point     */
   break;
   }
 break;
}


[Back] [Next]