Loading ...
Sorry, an error occurred while loading the content.

Minor artefact with CScrollWindowImpl...

Expand Messages
  • Philippe
    Hi Nenad, I have controls derived from CScrollWindowImpl and particularly a DataGrid. I noticed that when I turned my mouse s wheel
    Message 1 of 2 , Jun 2, 2012
    • 0 Attachment
      Hi Nenad,

      I have controls derived from 'CScrollWindowImpl<MyControl, CFSBWindow>' and particularly a DataGrid.
      I noticed that when I turned my mouse's wheel (even if I dont need to scroll) some parts of my control were flickering.
      So I checked the atlscrl.h file's code, more precisely CScrollImpl and the OnMouseWheel handler (line #491 for the latest version of WTL) and found this:

      if(m_sizeAll.cy > m_sizeClient.cy)
      {
      for(int i = 0; i < zTotal; i += WHEEL_DELTA)
      {
      pT->DoScroll(SB_VERT, nScrollCode, (int&)m_ptOffset.y, m_sizeAll.cy, m_sizePage.cy, m_sizeLine.cy);
      pT->UpdateWindow();
      }
      }
      else // can't scroll vertically, scroll horizontally
      {
      for(int i = 0; i < zTotal; i += WHEEL_DELTA)
      {
      pT->DoScroll(SB_HORZ, nScrollCode, (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx);
      pT->UpdateWindow();
      }
      }

      This code means that if the mouse's wheel is turned then
      if(m_sizeAll.cy > m_sizeClient.cy)
      it will scroll vertically and update (repaint) the client rect of the control
      else
      it will scroll horizontally and update (repaint) the client rect of the control

      Which is by the way a very good idea.

      But before scrolling horizontally (and update the window) we have to check if it is necessary and it is necessary only
      if(m_sizeAll.cx > m_sizeClient.cx) as there's no reason to scroll horizontally if the control width is not larger than the client width ;o)

      I modified it like this:

      if(m_sizeAll.cy > m_sizeClient.cy)
      {
      for(int i = 0; i < zTotal; i += WHEEL_DELTA)
      {
      pT->DoScroll(SB_VERT, nScrollCode, (int&)m_ptOffset.y, m_sizeAll.cy, m_sizePage.cy, m_sizeLine.cy);
      pT->UpdateWindow();
      }
      }
      else // can't scroll vertically, scroll horizontally
      {
      if(m_sizeAll.cx > m_sizeClient.cx)
      {
      for(int i = 0; i < zTotal; i += WHEEL_DELTA)
      {
      pT->DoScroll(SB_HORZ, nScrollCode, (int&)m_ptOffset.x, m_sizeAll.cx, m_sizePage.cx, m_sizeLine.cx);
      pT->UpdateWindow();
      }
      }
      }

      and everything is perfect with my Grid, no more flickering!

      I know it's a minor problem but this flickering was so annoying so I hope it helps.
      Long live WTL and all the best to you and the WTL team.

      Philippe Marechal
    • Nenad Stefanović
      Hi Philippe, Thank you for pointing this out. Your solution is what should be there, so I will add it to the WTL code. Thanks, Nenad ... [Non-text portions of
      Message 2 of 2 , Jun 3, 2012
      • 0 Attachment
        Hi Philippe,

        Thank you for pointing this out. Your solution is what should be there, so
        I will add it to the WTL code.

        Thanks,
        Nenad




        On Sat, Jun 2, 2012 at 9:28 AM, Philippe <marechal.ph@...> wrote:

        > **
        >
        >
        > Hi Nenad,
        >
        > I have controls derived from 'CScrollWindowImpl<MyControl, CFSBWindow>'
        > and particularly a DataGrid.
        > I noticed that when I turned my mouse's wheel (even if I dont need to
        > scroll) some parts of my control were flickering.
        > So I checked the atlscrl.h file's code, more precisely CScrollImpl and the
        > OnMouseWheel handler (line #491 for the latest version of WTL) and found
        > this:
        >
        > if(m_sizeAll.cy > m_sizeClient.cy)
        > {
        > for(int i = 0; i < zTotal; i += WHEEL_DELTA)
        > {
        > pT->DoScroll(SB_VERT, nScrollCode, (int&)m_ptOffset.y, m_sizeAll.cy,
        > m_sizePage.cy, m_sizeLine.cy);
        > pT->UpdateWindow();
        > }
        > }
        > else // can't scroll vertically, scroll horizontally
        > {
        > for(int i = 0; i < zTotal; i += WHEEL_DELTA)
        > {
        > pT->DoScroll(SB_HORZ, nScrollCode, (int&)m_ptOffset.x, m_sizeAll.cx,
        > m_sizePage.cx, m_sizeLine.cx);
        > pT->UpdateWindow();
        > }
        > }
        >
        > This code means that if the mouse's wheel is turned then
        > if(m_sizeAll.cy > m_sizeClient.cy)
        > it will scroll vertically and update (repaint) the client rect of the
        > control
        > else
        > it will scroll horizontally and update (repaint) the client rect of the
        > control
        >
        > Which is by the way a very good idea.
        >
        > But before scrolling horizontally (and update the window) we have to check
        > if it is necessary and it is necessary only
        > if(m_sizeAll.cx > m_sizeClient.cx) as there's no reason to scroll
        > horizontally if the control width is not larger than the client width ;o)
        >
        > I modified it like this:
        >
        > if(m_sizeAll.cy > m_sizeClient.cy)
        > {
        > for(int i = 0; i < zTotal; i += WHEEL_DELTA)
        > {
        > pT->DoScroll(SB_VERT, nScrollCode, (int&)m_ptOffset.y, m_sizeAll.cy,
        > m_sizePage.cy, m_sizeLine.cy);
        > pT->UpdateWindow();
        > }
        > }
        > else // can't scroll vertically, scroll horizontally
        > {
        > if(m_sizeAll.cx > m_sizeClient.cx)
        > {
        > for(int i = 0; i < zTotal; i += WHEEL_DELTA)
        > {
        > pT->DoScroll(SB_HORZ, nScrollCode, (int&)m_ptOffset.x, m_sizeAll.cx,
        > m_sizePage.cx, m_sizeLine.cx);
        > pT->UpdateWindow();
        > }
        > }
        > }
        >
        > and everything is perfect with my Grid, no more flickering!
        >
        > I know it's a minor problem but this flickering was so annoying so I hope
        > it helps.
        > Long live WTL and all the best to you and the WTL team.
        >
        > Philippe Marechal
        >
        >
        >


        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.