Linie wird nicht gezeichnet



  • long GridControl::OnPaint(WPARAM wparam, LPARAM lparam)
    {
    	if(GetUpdateRect(m_hwnd, NULL, 0))
    	{
    		PAINTSTRUCT ps;
    		HDC hdc;
    		bool callpaint = true;
    
    		if(wparam)
    		{
    			hdc = (HDC)wparam;
    			callpaint = false;
    		}
    
    		if(callpaint)
    			BeginPaint(m_hwnd,&ps);
    
    		//drawing the grid
    		RECT rect;
    		GetClientRect(m_hwnd, &rect);
    
    		HPEN blackpen = CreatePen(PS_SOLID, 1, RGB(0x00, 0x00, 0x00));
    		HPEN oldpen = (HPEN)SelectObject(hdc, (HGDIOBJ)blackpen);
    
    		for(long y = 0; y < rect.bottom - rect.top; y += m_gridy)
    		{
    			for(long x = 0; x < rect.right - rect.left; x += m_gridx)
    			{
    				MoveToEx(hdc, x, y, NULL);
    				LineTo(hdc, x + m_gridx, y + m_gridy);
    			}
    		}
    
    		DeleteObject(SelectObject(hdc, (HGDIOBJ)oldpen));
    
    		if(callpaint)
    			EndPaint(m_hwnd,&ps);
    	}
    	return 0; 
    }
    

    die funktion wird ausgeführt;
    es erscheinen aber keine schwarzen linien.
    Tipp?
    OS: XP Pro



  • Tipp: Code vereinfachen. Dann findet man den Fehler besser. 😉



  • mist; ich hab den hdc nicht auf den return-wert von Beginpaint gesetzt


Anmelden zum Antworten