简体   繁体   English

WTL RedrawWindow参数

[英]WTL RedrawWindow parameterrs

I'm new to the WTL C++. 我是WTL C ++的新手。 I'm really confused about the parameters that go into the RedrawWindows function especially for the flags. 我真的很困惑RedrawWindows函数中的参数,尤其是对于标志。 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,

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... 我试着将所有的null都减去最后一个,但是Visual Studio表示即使我读了msdn microsoft,该函数也没有4个参数。

You are not calling the global RedrawWindow . 您没有调用全局RedrawWindow

You're calling the member function CWindow::RedrawWindow , which takes 3 parameters. 您正在调用成员函数CWindow::RedrawWindow ,该函数具有3个参数。

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. 编辑:这三个参数都具有默认参数 ,这意味着它们不需要单独提供, RedrawWindow()应该可以工作。

This is not the way you should use and you are supposed to be using the API. 这不是应该使用的方式,应该使用API​​。 Your mouse button handler should call Invalidate() or InvalidateRect with specific part of the window you are marking as needing an update. 您的鼠标按钮处理程序应使用您标记为需要更新的窗口的特定部分来调用Invalidate()InvalidateRect Your window will then receive WM_PAINT event at the first OS convenience and your paint handler would paint the line. 然后,您的窗口将在第一个OS方便时收到WM_PAINT事件,并且您的绘制处理程序将绘制该行。

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. RedrawWindow这次可能会RedrawWindow ,但是很可能很快就会成为下一个问题的基础,因为您已经走错了路。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM