Several things:

[CODE]
void CEditorDoc::SetSquareColor(int i, int j, COLORREF color)
{
ASSERT( i >= 0 && i <= GetGridY() && j >= 0 && j <= GetGridX() );
m_clrGrid.At(i, j) = color;
SetModifiedFlag(TRUE);
CRect pRect( 20, -10, 30, -20 );
UpdateAllViews( NULL, 1, ( CObject* )&pRect);
}
[\CODE]

Will not work as the pRect vzariable is local will probably go out of scope if UpdateAllViews is posting messages...

In your square drawing code (besides thte advice that Mathew gave you) you're continually recalculating the x & y's for the rect. You should move the y calculation to the outer loop as it will be the same for each j:

[CODE]
//
//Draw the squares
//
CRect rect;

rect.top = -10;
rect.bottom = -20;

for(int i = 0 ; i < 500 ; i ++)
{
rect.left = 10;
rect.right = 20;

for(int j = 0 ; j < 750 ; j ++)
{
COLORREF color = pDoc->GetSquareColor(i, j);
pDC->FillSolidRect(rect, color);

rect.left += 10;
rect.right += 10;
}

rect.top -= 10;
rect.bottom -= 20;
}
[\CODE]
Note: I did not compile this code!!!

This should help with some of the speed problems. Another optimization would be to get the clip region and only draw the rects that are contained inside of the clip regions bounding rect.