Search code examples
c++redrawwtl

WTL RedrawWindow parameterrs


I'm new to the WTL C++. I'm really confused about the parameters that go into the RedrawWindows function especially for the flags. I'm just trying to update a window everytime I draw a line, but I don't exactly understand how

LRESULT  CDrawView::OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    int xPos= GET_X_LPARAM(lParam);
    int yPos = GET_Y_LPARAM(lParam);
    end.X = xPos;
    end.Y = yPos;

    Pen pen(Color(0, 0, 255));
    m_GraphicsImage.DrawLine(&pen, start.X, start.Y, end.X, end.Y);

I try to call RedrawWindow here,

RedrawWIndow(NULL,NULL, NULL, RDW_INTERNALPAINT) 

So everytime I release the left mouse button the window gets updated. I'm having a really hard time understanding the parameters that go into the Redraw Function. I tried putting them all null minus the last one but Visual studio says that the function doesn't take 4 parameters even though I read the msdn microsoft...


Solution

  • You are not calling the global RedrawWindow.

    You're calling the member function CWindow::RedrawWindow, which takes 3 parameters.

    BOOL RedrawWindow(
       LPCRECT lpRectUpdate = NULL,
       HRGN hRgnUpdate = NULL,
       UINT flags = RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE 
    ); throw() 
    

    Edit: These three parameters all have default arguments, meaning they don't need to be supplied an RedrawWindow() alone should work.