newntui/activex/Impact/src/ArgumentsTableCtrl.cpp
// HitTestEx	- Determine the row index and column index for a point
// Returns	- the row index or -1 if point is not over a row
// point	- point to be tested.
// col		- to hold the column index
HitTestEx      - Determine the row index and column index for a point
Returns        - the row index or -1 if point is not over a row
point  - point to be tested.
col            - to hold the column index
HitTestEx - Determine the row index and column index for a point Returns - the row index or - 1 if point is not over a row point - point to be tested . col - to hold the column index
int CArgumentsTableCtrl::HitTestEx(CPoint &point, int *col) const
{
	int colnum = 0;
	int row = HitTest( point, NULL );
	if( col ) *col = 0;
	if( (GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT )
		return row;
	row = GetTopIndex();
	int bottom = row + GetCountPerPage();
	if( bottom > GetItemCount() )
		bottom = GetItemCount();
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();
	for( ;row <=bottom;row++)
	{
		CRect rect;
		GetItemRect( row, &rect, LVIR_BOUNDS );
		if( rect.PtInRect(point) )
		{
			for( colnum = 0; colnum < nColumnCount; colnum++ )
			{
				int colwidth = GetColumnWidth(colnum);
				if( point.x >= rect.left 
					&& point.x <= (rect.left + colwidth ) )
				{
					if( col ) *col = colnum;
					return row;
				}
				rect.left += colwidth;
			}
		}
	}
	return -1;
}
int CArgumentsTableCtrl :: HitTestEx ( CPoint & point , int * col ) const { int colnum = 0 ; int row = HitTest ( point , NULL ) ; if ( col ) * col = 0 ; if ( ( GetWindowLong ( m_hWnd , GWL_STYLE ) & LVS_TYPEMASK ) != LVS_REPORT ) return row ; row = GetTopIndex ( ) ; int bottom = row + GetCountPerPage ( ) ; if ( bottom > GetItemCount ( ) ) bottom = GetItemCount ( ) ; CHeaderCtrl * pHeader = ( CHeaderCtrl * ) GetDlgItem ( 0 ) ; int nColumnCount = pHeader -> GetItemCount ( ) ; for ( ; row <= bottom ; row ++ ) { CRect rect ; GetItemRect ( row , & rect , LVIR_BOUNDS ) ; if ( rect . PtInRect ( point ) ) { for ( colnum = 0 ; colnum < nColumnCount ; colnum ++ ) { int colwidth = GetColumnWidth ( colnum ) ; if ( point . x >= rect . left && point . x <= ( rect . left + colwidth ) ) { if ( col ) * col = colnum ; return row ; } rect . left += colwidth ; } } } return -1 ; }
HitTestEx      - Determine the row index and column index for a point
Returns        - the row index or -1 if point is not over a row
point  - point to be tested.
HitTestEx - Determine the row index and column index for a point Returns - the row index or - 1 if point is not over a row point - point to be tested .
// Make sure that the ListView is in LVS_REPORT // Get the top and bottom row visible // Get the number of columns // Loop through the visible rows // Get bounding rect of item and check whether point falls in it. // Now find the column