Problem: 1655336

Title: TGridView::VPointToLastCell range problem (r12, r13a5)

Received: May 14 1997 8:37AM


I passed in a point that caused GridCell to return garbage for the "aCell" values (1638687146) for the v and h values (fNumcols=274, fNumRows=420). The formula for checking if invalid doesn't seem to handle this case (note this code is the same in r12 and r13a5:
GridCell TGridView::VPointToLastCell(const VPoint& aPoint) const
{
	GridCell aCell(fColWidths->FindItem(aPoint.h), fRowHeights->FindItem(aPoint.v));
	if (!aCell.h)                   // If its invalid, return the last column 
		aCell.h = fNumOfCols;
	if (!aCell.v)                   // If its invalid, return the last row 
		aCell.v = fNumOfRows;
	return aCell;
}
I think it should be:
	if (!aCell.h || aCell.h > fNumOfCols)   // If its invalid, return the last column 
		aCell.h = fNumOfCols;
	if (!aCell.v || aCell.v > fNumOfRows)   // If its invalid, return the last row 
		aCell.v = fNumOfRows;

Fix: He's right. We should check for high out of bounds as well as low out of bounds. His supplied code does the trick in UGridView.cp.