Our application creates an overlay window of a custom shape using the SetWindowRgn()
API in its OnPaint()
function. This region window only has a client area. It also has an owner window which is a regular rectangular window.
We have observed that sometimes the SetWindowRgn()
call in OnPaint()
takes a long time to return if the shape of the region is complex, for example, if the window region is a text or a complex design. Even the window below this region window renders slowly. This mostly occurs on resizing the view. What we have found is that OnNcCalcSize()
gets called from inside SetWindowRgn()
and the default handling of OnNcCalcSize()
takes a long time to return. Also, on some machines, the painting of the window below the region window is very slow.
Why does the rendering of a region window become slow for complex shapes? Can we make it faster by custom handling of events like OnNcCalcSize()
or other events?
NOTE: Please don't suggest using a Layered window as a technical limitation has forced us to use a region window.