加了被注釋的代碼後就會asserted...
void C技能實踐View::OnDraw(CDC* pDC)
{
C技能實踐Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: 在此處為本機數據添加繪制代碼
/*
static int i = 0;
m_chessboard.LoadBitmap(IDB_BITMAP1);
if (i == 0) {
Chessboard.CreateCompatibleDC(pDC);
Chessboard.SelectObject(m_chessboard);
pDC->BitBlt(0, 0, 800, 600, &Chessboard, 0, 0, SRCCOPY);
i = 1;
}
*/
}
找到原因了,是m_chessboard.LoadBitmap(IDB_BITMAP1);加載位圖的這一行要放到if裡面