gvg@svn.reactos.com wrote:
- if (GetUpdateRect(hWnd,
&rcUpdate,FALSE))
The previous code was perfectly valid. Why did you change it? If GetUpdateRect returns FALSE then there's no need to call BeginPaint...
- Filip
From: Filip Navara
The previous code was perfectly valid. Why did you change it? If GetUpdateRect returns FALSE then there's no need to call BeginPaint...
Possibly I fixed it wrong. Try minimizing the window with the old code. This will set the WINDOWOBJECT_NEED_NCPAINT flag. As a result, an endless stream of WM_PAINT messages is generated, 'cause that flag is never reset. Calling BeginPaint resets the flag.
GvG
Ge van Geldorp wrote:
From: Filip Navara
The previous code was perfectly valid. Why did you change it? If GetUpdateRect returns FALSE then there's no need to call BeginPaint...
Possibly I fixed it wrong. Try minimizing the window with the old code. This will set the WINDOWOBJECT_NEED_NCPAINT flag. As a result, an endless stream of WM_PAINT messages is generated, 'cause that flag is never reset. Calling BeginPaint resets the flag.
I overlooked that the code used GetUpdateRect with the last parameter set to FALSE, it should be set to TRUE. In that case GetUpdateRect is responsible for sending the WM_NCPAINT message and cleaning the update region.
- Filip
Filip Navara wrote:
I overlooked that the code used GetUpdateRect with the last parameter set to FALSE, it should be set to TRUE. In that case GetUpdateRect is responsible for sending the WM_NCPAINT message and cleaning the update region.
No, that shouldn't be a problem. The last parameter just specifies if the update region is supposed to be erased (by sending a WM_ERASEBKGND message). It doesn't affect the validation of update region at all. Having it set to TRUE will likely cause more flickering because it's not needed to fill the area.
- Thomas
From: Thomas Weidenmueller
Filip Navara wrote:
I overlooked that the code used GetUpdateRect with the last parameter set to FALSE, it should be set to TRUE. In that case GetUpdateRect is responsible for sending the WM_NCPAINT message and cleaning the update region.
No, that shouldn't be a problem. The last parameter just specifies if the update region is supposed to be erased (by sending a WM_ERASEBKGND message). It doesn't affect the validation of update region at all.
According to MSDN, you're right, it doesn't mention GetUpdateRect sending a WM_NCPAINT message. According to the attached test program (gcc -o gurtest.exe gurtest.c -lgdi32, click inside the window to invalidate the whole window), Filip is right and a WM_NCPAINT is actually sent from within GetUpdateRect.
GvG
Ge van Geldorp wrote:
According to MSDN, you're right, it doesn't mention GetUpdateRect sending a WM_NCPAINT message. According to the attached test program (gcc -o gurtest.exe gurtest.c -lgdi32, click inside the window to invalidate the whole window), Filip is right and a WM_NCPAINT is actually sent from within GetUpdateRect.
I get the messages in the following order:
received WM_NCPAINT Before GetUpdateRect After GetUpdateRect
However, but the fact that WM_NCPAINT is sent shouldn't be influenced by GetUpdateRect's last parameter IMO.
- Thomas
From: Thomas Weidenmueller
I get the messages in the following order:
received WM_NCPAINT Before GetUpdateRect After GetUpdateRect
That's during the initial paint, the WM_NCPAINT is sent during window creation then so there's no need for GetUpdateRect to send it again. Try clicking in the window, this will invalidate the window and then you'll see "before, WM_NCPAINT, after".
GvG
Ge van Geldorp wrote:
From: Thomas Weidenmueller
I get the messages in the following order:
received WM_NCPAINT Before GetUpdateRect After GetUpdateRect
That's during the initial paint, the WM_NCPAINT is sent during window creation then so there's no need for GetUpdateRect to send it again. Try clicking in the window, this will invalidate the window and then you'll see "before, WM_NCPAINT, after".
In Windows there are basically four low-level places where WM_NCPAINT is sent:
- In BeginPaint before anything else is done. - In GetUpdateRect/GetUpdateRgn if fErase is set to TRUE. [This is what GvG reported with the test application.] - In RedrawWindow if RDW_ERASENOW or RDW_UPDATENOW is specified. [This is what Thomas is seeing on the application startup AFICT, it comes from the ShowWindow call I'd guess.] - In DispatchMessage if WM_PAINT was sent to the application and it wasn't processed. There is an internal flag that is set before the message is passed to application and this flag is cleared by GetUpdateRect/GetUpdateRgn/BeginPaint (if appropriate) and after returning from the application it is checked. Actually this is just a hack to support broken applications, but we need to implement it anyway (and it's not implemented yet).
Actually this gets a bit trickier with the WM_SYNCPAINT messages, but since we don't use them only the places above should be assumed.
Best regards, Filip