C++ MFC 雙緩沖 輸出19條橫線19條豎線,寫在ondraw函數裡,沒有報錯,但是窗體裡什麼都沒有輸出……
代碼如下:
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
CBitmap GoBoardMap;
CRect rect;
GetClientRect(&rect);
GoBoardMap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
float goblenth = min(rect.Width(), rect.Height())*0.9; //定位用
float gobwidthsingle = goblenth / 18; //定位用
float gostartx = (rect.Width() - goblenth) / 2; //定位用
float gostarty = (rect.Height() - goblenth) / 2; //定位用
Graphics graphics(dcMemory);
Pen* myPen=new Pen(Color::Black,1);
int i, j;
for (i = 0; i <= 18; i++) //畫橫線 19條
{
graphics.DrawLine(myPen, gostartx + gobwidthsingle*i, gostarty, gostartx + gobwidthsingle*i,
gostarty + goblenth);
}
for (j = 0; j <= 18; j++) //畫豎線 19條
{
graphics.DrawLine(myPen, gostartx, gostarty + gobwidthsingle*j, gostartx + gobwidthsingle*j,gostarty + goblenth);
//graphics.DrawImage();
}
pDC->BitBlt(gostartx, gostarty, goblenth, goblenth, &dcMemory, 0, 0, SRCCOPY);
dcMemory.DeleteDC();
拜求高手…… 幫忙看下哪兒出了問題…… 謝謝
Graphics 初始化了嗎:
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken,&gdiplusStartupInput,NULL);