在 c++ 中的 win32 中做一个项目,试图双缓冲正在绘制的图像,但我得到一个黑屏,上面绘制了正确的位图。这也导致了我的 WM_MOUSEMOVE 条件,它与光标一起拖动位图而不绘制位图。绘制代码如下:在WM_PAINT下的wndproc中调用paint(),scroll是滚动条的位置,目前未使用。
int paint(HWND hWnd, HINSTANCE hInst, RECT clientRect, std::vector<Measure> *measures, int scroll)
{
int x = 90;
hdc = BeginPaint(hWnd, &ps);
hdcmem = CreateCompatibleDC(hdc);
HBITMAP hbmScreen = CreateCompatibleBitmap(hdc, clientRect.right, clientRect.bottom);
SelectObject(hdcmem,hbmScreen);
/*these functions just create the bitmaps into hdcmem*/
drawStaff(hWnd, hInst, clientRect, x, 0);
drawKey(hWnd, hInst, clientRect, x, (*measures)[0], 0);
drawTime(hWnd, hInst, clientRect, x, (*measures)[0], 0);
drawNotes(hWnd, hInst, clientRect, measures, x);
BitBlt(hdc, 0, 0, clientRect.right, clientRect.bottom, hdcmem, 0, 0, SRCCOPY);
ReleaseDC(hWnd, hdcmem);
return 0;
}