Pregunta

Haciendo un proyecto en Win32 en C ++, intentando buffer duplicar la imagen que se dibuja, pero estoy obteniendo una pantalla negra con los mapas de bits correctos sobre ella. Esto también está causando que mi condición WM_MouseMove, que arrastra un mapa de bits junto con su cursor para no dibujar el mapa de bits. El código para la pintura está a continuación: la pintura () se llama en wndproc en wm_paint, el desplazamiento es la posición de la barra de desplazamiento, no utilizada hasta ahora.

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;
}
¿Fue útil?

Solución

Debe llenar el mapa de bits con cualquier color de fondo que sea primero antes de dibujar sus otros gráficos. Si la memoria me sirve correctamente, los mapas de bits están llenos de negro de forma predeterminada cuando se crean.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top