Recording a particular "View" or "Area" during scrolling.
I was worrying myself over the following problem:
Consider a CEdit control in a scrollable window. When the window is scrolled and consequently the CEdit control is scrolled out of view, the blinking cursor still follows to the next scrolled region. I assumed this was because the CEdit still retained focus and demanded to be present in the scrolled area. This is of course highly undesirable and what I wish is for the CEdit to retain focus only when it is scrolled back into view.
So I recorded the values of m_nHScrollPos and m_nVScrollPos in separate variables, nHScreenView and nVScreenView respectively upon creation of the CEdit control. I then ordered the CEdit control to be destroyed as soon as the window was scrolled (at the very end of the OnVScroll, OnHScroll functions). Finally I use this code to recreate the CEdit control when the area containing the CEdit control is scrolled into view. Again this code is present at the end of the WM_*SCROLL message functions.