NcPaint and Invalid rect/region
-
Just in few words my question is next: Is there a way to get current invalid region when CWnd gets WM_NCPAINT message (in OnNcPaint() handler)? Details: I have a main frame with few child dialogs placed on it. Dialogs have custom controls. Custom controls have specific non-client area and that area is drawn when the control gets WM_NCPAINT message. Now I want to invalidate (redraw) only a small part of my main frame calling InvalidateRgn(&invalidRgn). If that invalid area overlaps with control's non-client area - WM_NCPAINT is sent to the control. Code in control's OnNcPaint() is like this:
void CMyCtrl::OnNcPaint()
{
CWindowDC dc(this);
// dc.SelectClipRgn(&invalidRgn) ???
DoPaint(&dc);
...
}And it paints over all window dc of the control. Whole non-client area is repainted, not only invalid region which I've passed when called InvalidateRgn(&invalidRgn). That is a behaviour I want to get rid of. I need only invalid region to be repainted. My suggestion is that I need somehow to get current invalid region and select it before painting like
dc.SelectClipRgn(&invalidRgn)
So the question is can I do that? and if yes - how?
-
Just in few words my question is next: Is there a way to get current invalid region when CWnd gets WM_NCPAINT message (in OnNcPaint() handler)? Details: I have a main frame with few child dialogs placed on it. Dialogs have custom controls. Custom controls have specific non-client area and that area is drawn when the control gets WM_NCPAINT message. Now I want to invalidate (redraw) only a small part of my main frame calling InvalidateRgn(&invalidRgn). If that invalid area overlaps with control's non-client area - WM_NCPAINT is sent to the control. Code in control's OnNcPaint() is like this:
void CMyCtrl::OnNcPaint()
{
CWindowDC dc(this);
// dc.SelectClipRgn(&invalidRgn) ???
DoPaint(&dc);
...
}And it paints over all window dc of the control. Whole non-client area is repainted, not only invalid region which I've passed when called InvalidateRgn(&invalidRgn). That is a behaviour I want to get rid of. I need only invalid region to be repainted. My suggestion is that I need somehow to get current invalid region and select it before painting like
dc.SelectClipRgn(&invalidRgn)
So the question is can I do that? and if yes - how?
GetUpdateRect API call retrieves the smallest bounding rectangle that encloses the update region and does the same function as BeginPaint which is only for use in WM_PAINT calls. Which answers your question ... My suggestion is that I need somehow to get current invalid region? ... and yes you can set it as a clip for your drawing if you want.
In vino veritas
-
GetUpdateRect API call retrieves the smallest bounding rectangle that encloses the update region and does the same function as BeginPaint which is only for use in WM_PAINT calls. Which answers your question ... My suggestion is that I need somehow to get current invalid region? ... and yes you can set it as a clip for your drawing if you want.
In vino veritas
GetUpdateRect returns only client area coordinates that should be updated. I need whole control's invalid area including non-client parts. Actually seems I've already find an answer: when Windows send WM_NCPAINT message it puts invalid region handle into wParam, but seems in coordinates relative to the desktop, - that's what I was looking for.