HDC hDC = GetDC(hWnd);
HDC memDC = ::CreateCompatibleDC(hDC);
int x = m_pWndRect.left, y = m_pWndRect.top;
//画水平线
int nHeight = m_pWndRect.bottom - 200;
int nWidth = m_pWndRect.right - 200; HBITMAP hBitmap = ::CreateCompatibleBitmap(hDC, nWidth, nHeight);
HBITMAP hOldBitmap = (HBITMAP)SelectObject(memDC, hBitmap); for (y = m_pWndRect.top; y < nHeight; y += m_nYSpacing)
{
::MoveToEx(memDC, x, y, NULL);
::LineTo(memDC, x + (nWidth - x), y);
} //画垂直线
x = m_pWndRect.left, y = m_pWndRect.top;
for (x = m_pWndRect.left; x < nWidth; x += m_nXSpacing)
{
::MoveToEx(memDC, x, y, NULL);
::LineTo(memDC, x, y + (nHeight - y));
}
BitBlt(hDC, m_pWndRect.left, m_pWndRect.top, nWidth, nHeight, memDC, 0, 0, SRCCOPY);
SelectObject(memDC, hOldBitmap);
DeleteObject(hBitmap);
ReleaseDC(hWnd, memDC);执行后显示黑图啊```估计是画线那些地方没画上``但是我试过把画线的地方改成画矩形或FillRect,却是可以画出来的`请教``有什么问题吗
HDC memDC = ::CreateCompatibleDC(hDC);
int x = m_pWndRect.left, y = m_pWndRect.top;
//画水平线
int nHeight = m_pWndRect.bottom - 200;
int nWidth = m_pWndRect.right - 200; HBITMAP hBitmap = ::CreateCompatibleBitmap(hDC, nWidth, nHeight);
HBITMAP hOldBitmap = (HBITMAP)SelectObject(memDC, hBitmap); for (y = m_pWndRect.top; y < nHeight; y += m_nYSpacing)
{
::MoveToEx(memDC, x, y, NULL);
::LineTo(memDC, x + (nWidth - x), y);
} //画垂直线
x = m_pWndRect.left, y = m_pWndRect.top;
for (x = m_pWndRect.left; x < nWidth; x += m_nXSpacing)
{
::MoveToEx(memDC, x, y, NULL);
::LineTo(memDC, x, y + (nHeight - y));
}
BitBlt(hDC, m_pWndRect.left, m_pWndRect.top, nWidth, nHeight, memDC, 0, 0, SRCCOPY);
SelectObject(memDC, hOldBitmap);
DeleteObject(hBitmap);
ReleaseDC(hWnd, memDC);执行后显示黑图啊```估计是画线那些地方没画上``但是我试过把画线的地方改成画矩形或FillRect,却是可以画出来的`请教``有什么问题吗
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货