Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » I want to acquire width of a Grid cell Collapse All
Subject Author Date
tera t Sep 4, 2007 - 3:13 AM

Hello.

Because I want to acquire cell width.
I become a const error when I make the following sauce.

void CMuGrid::OnGbwAdjustRects(
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType,
RECT & rcCellExtraA,
RECT & rcCellA
) const
{
CExtGridWnd::OnGbwAdjustRects(
nColNo,
nRowNo,
nColType,
nRowType,
rcCellExtraA,
rcCellA
);

int ix;
ix = rcCellA.top;

if ( m_DwCopyFlag == true && nColType == 0 && nRowType == 0 ){
if ( m_CpRect.left == nColNo && m_CpRect.top == nRowNo ){
m_CpRectDraw.top = rcCellA.top;
m_CpRectDraw.left = rcCellA.left;
}
if ( m_CpRect.right == nColNo && m_CpRect.bottom == nRowNo ){
m_CpRectDraw.bottom = rcCellA.bottom;
m_CpRectDraw.right = rcCellA.right;
}
}
}

Will not there be a good method?

Technical Support Sep 4, 2007 - 10:29 AM

You can retrieve the coordinates of a cell (in the grid control’s client coordinate system) using the CExtGridWnd::GridCellRectsGet() method. This method allows you to get the entire cell rectangle and/or rectangles of cell parts.

CExtGridWnd & wndGrid = . . .
LONG nColNo = . . .
LONG nRowNo = . . .
CRect rcCellLocation;
	if( ! wndGrid.GridCellRectsGet(
			nColNo,
			nRowNo,
			0,
			0,
			NULL,
			&rcCellLocation
			)
		)
		return . . .
It returns true if the rcCellLocation rectangle was filled with correct cell rectangle coordinates and false if it is not possible to compute cell coordinates (the cell at column nColNo and row nRowNo is outside the visible cell range or method parameters are invalid).

You can also use the CExtGridCell::MeasureCell() method which measures the cell and returns its size in pixels.

tera t Sep 4, 2007 - 8:57 PM


Thank You!!