This example inverts a rectangle if the mouse button is released (WM_BUTTON1UP) within the rectangle (WinPtInRect); the presentation space handle is obtained via WinBeginPaint.

#define INCL_WINWINDOWMGR       /* Window Manager Functions     */
#include <os2.h>

BOOL  fSuccess;         /* success indicator                    */
HAB     hab;            /* anchor-block handle                  */
RECTL prclRect1 = {0,0,100,100}; /* rectangle                   */
HWND   hwnd;            /* client window handle                 */
HPS    hps;             /* presentation-space handle            */
POINTL ptl;             /* current mouse position               */
MPARAM mpParam1;        /* Parameter 1  (x,y) point value       */

case WM_BUTTON1UP:
     ptl.x = (LONG) SHORT1FROMMP(mpParam1);
     ptl.y = (LONG) SHORT2FROMMP(mpParam1);

     if (WinPtInRect(hab, &prclRect1, &ptl))
        {
        hps = WinBeginPaint(hwnd, NULLHANDLE, &prclRect1);
        fSuccess = WinInvertRect(hps, &prclRect1);
        WinEndPaint(hps);
        }


[Back] [Next]