Question

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...

Was it helpful?

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.

OTHER TIPS

This is not the way you should use and you are supposed to be using the API. Your mouse button handler should call Invalidate() or InvalidateRect with specific part of the window you are marking as needing an update. Your window will then receive WM_PAINT event at the first OS convenience and your paint handler would paint the line.

RedrawWindow might work out this time, however is likely to be a base of a next problem very soon because you are already on the wrong way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top