title: CScrollView Offset Client Rect with Scroll Position
body: <p>I am trying to write a function that will work out if the window that currently has focus is entirely shown in the client rect of my <code>CScrollView</code> but I am struggling to work out what I am doing wrong. This is what I have thus far:</p>
  
  <pre><code>CWnd * pWnd = pView-&gt;GetFocus();
  if(pWnd)
  {                               
      CRect winRect;
      pWnd-&gt;GetWindowRect(&amp;winRect);
      pView-&gt;ScreenToClient(&amp;winRect);    //pView is a pointer the CScrollView        
  
      CRect viewRect;
      pView-&gt;GetClientRect(&amp;viewRect);
  
      CPoint currentScrollPoint = pView-&gt;GetScrollPosition();
      viewRect.OffsetRect(currentScrollPoint);
  
      if(!(viewRect.PtInRect(winRect.BottomRight()) &amp;&amp; viewRect.PtInRect(winRect.TopLeft())))
      {
          //Not shown fully
      }
  }
  </code></pre>
  
  <p>Can anyone see what I am doing wrong here or suggest a better way of doing this?</p>