No need to write your own coordinate functions! Take a closer look at built-in CVI functions that compare point coordinates to the location of a rectangle area. Such functions are useful when locating mouse clicks on the front panel.
A great example that demonstrates the usefulness of this function is the Colview.cws example. This code shows how to use the Table control in an interactive way, by clicking on the table's column label will sort the list contents using that column as a key. The RectContainsPoint function helps us determine where the mouse click occurred, specifically which column label is clicked by the user.
Here is the Code snippet that uses RectContainsPoint to determins the column label clicked on.
All Rectangle and Point functions can be found in the User Interface Library as seen below.
Below is a further description of the RectContainsPoint function taken from CVI Help.
RectContainsPoint
int RectContainsPoint (Rect rect, Point point);
Purpose
Returns 1 if the specified rectangle encloses the point you specify. The function returns 0 otherwise.
The rectangle is considered to enclose the point if the point is in the interior of the rectangle or on its frame.
Parameters
Input |
Name | Type | Description |
rect | Rect | The location and size of a rectangle. |
point | Point | The location of the center of the rectangle. |
Return Value
Name | Type | Description |
containsPoint | int | Indicates if rect contains point.Code | Description | 1 | point is in the interior or on the frame of the rectangle specified by rect. | 0 | point is outside the frame of the rectangle specified by rect. |
|
Refer to userint\colview.cws for an example of using the RectContainsPoint function.
Did you find this tip useful? Rate this document or add a comment below.