2.2.6.17.10 GridControl::FindCell


Description

Convert a screen-coordinates position to grid control's 0-offset row/column index.

Syntax

bool FindCell( int nx, int ny, int & nRow, int & nCol )

Parameters

nx
[input] the horizontal position in screen coordinates
ny
[input] the vertical position in screen coordinates
nRow
[output] 0-offset row index
nCol
[output] 0-offset column index

Return

false if the position is not in grid otherwise true

Examples

Example codes can be added to GridControl's examples to run

ON_CONTEXTMENU(OnRightClick) //add to class GridCtrlDLG's Message Map 

//add in class GridCtrlDLG
	BOOL OnRightClick(UINT nResIDCtrl, int nx, int ny)
	{
		if(IDC_GRID == nResIDCtrl)
		{
			int nRow, nCol;
			if( m_GridCtrl.FindCell(nx, ny, nRow, nCol) )
				printf("nRow=%d, nCol=%d\n", nRow, nCol);
			else
				out_str("not in grid");
		}
		return true;
	}

Remark

See Also

GridControl::GetSelCell

Header to Included

GridControl.h