我用CreateCompatibleDC创建了一个dc的内存,我想让它区域(0, 0, 640, 480)填充RGB(255, 0, 255), 该如何做?这块DC得内存,并不是马上用来显示,而是要做一些其他运算。
我写了个测试程序。如下
HDC hMemDc, hPaintDc;
HBRUSH hBrush; hPaintDc = ::GetDC(m_hWnd);
if(hPaintDc == NULL)
return; hMemDc = ::CreateCompatibleDC(NULL);
if(hPaintDc == NULL)
return; hBrush = ::CreateSolidBrush(TRANSPARENTCOLOR);
if(hBrush == NULL)
return;
FillRect(hMemDc, &m_rectDlg, hBrush);
::BitBlt(hPaintDc, 0, 0, m_rectDlg.right, m_rectDlg.bottom, hMemDc, 0, 0, SRCCOPY); ::DeleteDC(hPaintDc);
::DeleteDC(hMemDc);
::DeleteObject(hBrush);但是,不没有在对话框上出现想要的粉红色
我写了个测试程序。如下
HDC hMemDc, hPaintDc;
HBRUSH hBrush; hPaintDc = ::GetDC(m_hWnd);
if(hPaintDc == NULL)
return; hMemDc = ::CreateCompatibleDC(NULL);
if(hPaintDc == NULL)
return; hBrush = ::CreateSolidBrush(TRANSPARENTCOLOR);
if(hBrush == NULL)
return;
FillRect(hMemDc, &m_rectDlg, hBrush);
::BitBlt(hPaintDc, 0, 0, m_rectDlg.right, m_rectDlg.bottom, hMemDc, 0, 0, SRCCOPY); ::DeleteDC(hPaintDc);
::DeleteDC(hMemDc);
::DeleteObject(hBrush);但是,不没有在对话框上出现想要的粉红色
该用那个api函数
HDC hMemDc, hPaintDc;
HBRUSH hBrush; hPaintDc = ::GetDC(m_hWnd);
if(hPaintDc == NULL)
return; hMemDc = ::CreateCompatibleDC(hPaintDc);
if(hMemDc == NULL)
return; hBrush = ::CreateSolidBrush(TRANSPARENTCOLOR);
if(hBrush == NULL)
return;
HBITMAP hBitmap = CreateCompatibleBitmap(hPaintDc);
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDc, hBitmap); FillRect(hMemDc, &m_rectDlg, hBrush);
::BitBlt(hPaintDc, 0, 0, m_rectDlg.right, m_rectDlg.bottom, hMemDc, 0, 0, SRCCOPY); SelectObject(hMemDc, hOldBitmap);
DeleteObject(hBitmap);
::DeleteDC(hPaintDc);
::DeleteDC(hMemDc);
::DeleteObject(hBrush);