How can I make the last column fill the rest of the windows area? In other words, I don't want that an empty gray area appears after the last column.

You should override GetColWidth() as follows:

int CDaoQueryView::GetColWidth(ROWCOL nCol)
{
   int nWidth = CGXGridCore::GetColWidth(nCol);
   // Make the last column fill the rest of the window so that
   // no empty space is visible.
   if (!IsPrinting() && nCol == GetColCount())
   {
      CRect rect = GetGridRect();
      nCol = GetClientCol(nCol);
      if (nCol > 0)
         nWidth = max(nWidth, rect.Width() - CalcSumOfClientColWidths(0, nCol-1) - 1);
   }
   return nWidth;
}

This could be done the same way with GetRowHeight().