WinPtInRect: Difference between revisions
Appearance
Created page with "This function ''queries whether a point lies within a rectangle''. ==Syntax== WinPtInRect(hab, prcl, pptl) ==Parameters== ;hab (HAB) - Input : Anchor-block handle. ;prcl (PRECTL) - Input : Rectangle to be queried. :;Note :: The value of each field in this structure must be in the range -32 768 through 32 767. The data type WRECT may also be used, if supported by the language. ;pptl (PPOINTL) - Input : Point to be queried. ==Returns== ;rc (BOOL) -..." |
|||
Line 87: | Line 87: | ||
* [[WinIsRectEmpty]] | * [[WinIsRectEmpty]] | ||
* [[WinOffsetRect]] | * [[WinOffsetRect]] | ||
* [[WinSetRect]] | * [[WinSetRect]] | ||
* [[WinSetRectEmpty]] | * [[WinSetRectEmpty]] |
Latest revision as of 03:13, 9 April 2025
This function queries whether a point lies within a rectangle.
Syntax
WinPtInRect(hab, prcl, pptl)
Parameters
- hab (HAB) - Input
- Anchor-block handle.
- prcl (PRECTL) - Input
- Rectangle to be queried.
- Note
- The value of each field in this structure must be in the range -32 768 through 32 767. The data type WRECT may also be used, if supported by the language.
- pptl (PPOINTL) - Input
- Point to be queried.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE
- pptl lies within prcl.
- FALSE
- pptl does not lie within prcl, or an error occurred.
Remarks
(No additional remarks were provided in the original text.)
Errors
Possible returns from WinGetLastError: (No specific errors were listed in the provided text.)
Example Code
#define INCL_WINRECTANGLES /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HAB hab; /* Anchor-block handle. */ PRECTL prcl; /* Rectangle to be queried. */ PPOINTL pptl; /* Point to be queried. */ BOOL rc; /* Success indicator. */ rc = WinPtInRect(hab, prcl, pptl);
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; }