You can draw any grid background in a CExtGridWnd
-derived class by overriding the CExtGridWnd::OnGbwEraseArea()
virtual method. If the dwAreaFlags
parameter is set to __EGBWA_INNER_CELLS
, the rcArea
specifies the entire inner data cell area. Of course, you should detect whether you have any vertical space between the last row and rcArea.bottom.
You can use the following code to get the last visible row and the bottom margin:
CExtGridWnd * pGrid = ...
if( pGrid->RowCountGet() == 0 || pGrid->ColumnCountGet() == 0 )
return ...
CRect rcVisibleRange = pGrid->OnSiwGetVisibleRange();
CRect rcCellAtBottom;
if( ! pGrid->GridCellRectsGet( rcVisibleRange.left, rcVisibleRange.bottom, 0, 0, NULL, &rcCellAtBottom ) )
return ...
Now you can detect the area you need:
If( rcCellAtBottom.bottom >= rcArea.bottom ) // nowhere to paint
return ...
CRect rcAreaYouNeed( rcArea.left, rcCellAtBottom.bottom, rcArea.right, rcArea.bottom );