views:

662

answers:

3

I'm facing a problem on Win32 API. I have a program that when it handles WM_PAINT messages it calls BeginPaint to clip the region and validate the update region, but the BeginPaint() is always generating a WM_NCPAINT message with the same updata region even if the touched part that need repaint it's only inside the client region.

Do anyone has any clue? It's on child windows with WS_CHILD.

A: 

I guess, the WM_NCPAINT is sent always with the assumption that the border needs to be repainted as well!

Prakash
+1  A: 

The MSDN entry for WM_PAINT says:

"The function may also send the WM_NCPAINT message to the window procedure if the window frame must be painted and send the WM_ERASEBKGND message if the window background must be erased."

I'm trying to figure out why it is always sending even if the border isn't touched. I test that opening a small Notepad inside the control and minimizing. It doesn't touch the borders of the control, just inside and BeginPaint() generates a WM_NCPAINT.

Augusto Radtke
A: 

Wonder what happens if you call SetWindowPos with SWP_DEFERERASE as uFlags.

This should prevent generation of the WM_SYNCPAINT message which would indirectly causes WM_NCPAINT message sent.

Prakash
Window message spy shows that WM_SYNCPAINT isn't being generated. The problem happens when the window became dirty (something is over it and needs redraw when it's gone) and not from resizing. I'm thinking in forgetting BeginPaint() and getting the DC by myself and validating the region by "hand".
Augusto Radtke