Hit-Testing

Hit-testing is used to determine what is located under a given window coordinate. The method CGXGridCore::HitTest() computes a hit value for a given point.

The following hit values are defined:

  • GX_HORZLINE - The point is on the gridline of a row header.
  • GX_VERTLINE - The point is on the gridline of a column header.
  • GX_HEADERHIT - The point is on the interior rectangle of a row or column header.
  • GX_CELLHIT - The point is on the interior rectangle of a cell.
  • GX_SELEDGEHIT - The point is on the edge of a selection. This hit value will only be generated if m_bHitTestSelEdge is TRUE.
  • GX_NOHIT - No information is displayed at the point
  • One use of HitTest() is for a context-sensitive mouse cursor. Whenever the mouse is moved, the grid calls HitTest() and changes the mouse cursor as necessary.

    Note: GetRowCount() and GetColCount() are used extensively to validate values within routines. In addition, because HitTest() is called repeatedly on every mouse move and because this method touches a lot of grid code, including GetRowCount(), it is not unusual for GetRowCount() to be called thousands of times in a short period of time. Because GetRowCount() and GetColCount() are called quite often, your overrides of these methods are not an appropriate place to do extensive calculation.