Problem mit Memory DCs



  • also ich hab ein fenster dass ein graph zeichnen soll. In WM_CREATE wird ein DC im hauptspeicher erstellt und der graph wird dorthinein gezeichnet. in WM_PAINT wird er dann auf den bildschirm geblittet. Leider bleibt bei mir alles weiß 😃

    case WM_CREATE: //LPARAM = input
    		input = (PredatorPreyInput*)(((CREATESTRUCT*)lParam)->lpCreateParams);
    		points = Interpolate_Linear(*input, ComputePredatorPreyPoints(input));
    
    		hdcMem = CreateCompatibleDC(0);
    		hBitmap = CreateCompatibleBitmap(0, input->iLenght, input->iHeight);
    
    		//draw the graph:
    		for(int i=0;i<(input->iLenght);i++)
    		{
    			min = (int)min(points->Predator, points->Predator);
    			color = MixColor(input->PredatorColor, input->PreyColor);
    
    			hPen = CreatePen(PS_SOLID, 1, color);
    			SelectObject(hdcMem, hPen);
    			MoveToEx(hdcMem, i, 0, NULL);
    			LineTo(hdcMem, i, min);
    			if(points->Predator > points->Prey)
    			{
    				hPen = CreatePen(PS_SOLID, 1, input->PredatorColor);
    				DeleteObject(SelectObject(hdcMem, hPen));
    				MoveToEx(hdcMem, i, min, NULL);
    				LineTo(hdcMem, i, (int)points->Predator);
    			}
    			if(points->Prey > points->Predator)
    			{
    				hPen = CreatePen(PS_SOLID, 1, input->PreyColor);
    				DeleteObject(SelectObject(hdcMem, hPen));
    				MoveToEx(hdcMem, i, min, NULL);
    				LineTo(hdcMem, i, (int)points->Prey);
    			}
    		}
    		SetWindowLong(hwnd, GWL_USERDATA, (LONG)hdcMem);
    		break;
    
    case WM_PAINT:
    		hdc = BeginPaint(hwnd, &ps);
    		GetClientRect(hwnd, &rect);
     		BitBlt(hdc, rect.left, rect.top, rect.right, rect.bottom, (HDC)GetWindowLong(hwnd, GWL_USERDATA), 0, 0, SRCCOPY);
    		EndPaint(hwnd, &ps);
    		break;
    

    (int)points->Prey und (int)points->Predator stimmen (mit debugger ausgelesen).
    Leider komme ich im moment nichmehr weiter deshalb wollte ich euch fragen ob ihr einen fehler seht 😃



  • Du hast zwar nen hdcMem und nen hBitmap - Du selektierst die hBitmap aber nirgends in hdcMem!


Anmelden zum Antworten