GetTableCellFromPoint

int GetTableCellFromPoint (int panelHandle, int controlID, Point panelCoordinates, Point *cell);

Purpose

Converts panel coordinates into a table control cell.

GetTableCellFromPoint returns a cell containing the indices {0, 0} if the specified coordinates lie outside the cell grid.

Parameters

Input
Name Type Description
panelHandle integer Specifier for a particular panel that is currently in memory. You obtain this handle from LoadPanel, NewPanel, or DuplicatePanel.
controlID integer The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by NewCtrl or DuplicateCtrl.
panelCoordinates Point A Point structure specifying the panel coordinates.

The Point structure is defined as follows:

typedef struct
   {
   int x;
   int y;
   } Point;


The values in the Point structure are in terms of pixel coordinates. The origin (0,0) is the upper left corner of the panel.

You can create a Point without having to declare a variable by using the following function:

Point MakePoint (int x, int y);

Example

GetTableCellFromPoint (panelHandle, controlID, MakePoint (20, 30), &cell);

This function can return a cell that is scrolled out of view. If you want to restrict the specified coordinates to the visible portion of the table, you must use the following code:

Output

Name Type Description
cell Point (passed by reference) A Point structure indicating the row and column of the cell corresponding to the specified value.

The Point structure is defined as follows:

typedef struct
   {
   int x;
   int y;
   } Point;


The function writes the one-based column index of the corresponding cell into the x field of the structure, and the one-based row index of the corresponding cell into the y field of the structure.

If the specified coordinates lie outside the cell grid, the function returns a cell containing the indices {0, 0}.

This function can return a cell that is scrolled out of view. If you want to restrict the specified coordinates to the visible portion of the table, you must use the following code:

GetCtrlAttribute (panelHandle, controlID, ATTR_GRID_AREA_TOP, &top);
GetCtrlAttribute (panelHandle, controlID, ATTR_GRID_AREA_LEFT, &left);
GetCtrlAttribute (panelHandle, controlID, ATTR_GRID_AREA_WIDTH, &width);
GetCtrlAttribute (panelHandle, controlID, ATTR_GRID_AREA_HEIGHT, &height);

cell.x = 0;
cell.y = 0;

if (point.x >= left && point.x < left + width)
  if (point.y >= top && point.y < top + height)
   GetTableCellFromPoint (panelHandle, controlID, point, &cell);

Return Value

Name Type Description
status integer Return value indicating whether the function was successful. A negative number indicates that an error occurred.

Code Error Message String
xx Success