Minor artefact with CScrollWindowImpl...
"Philippe" <[email protected]> Sat, 02 Jun 2012 16:28:45 -0000
| Newsgroups | gmane.comp.windows.wtl |
|---|---|
| Message-ID | <[email protected]> |
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
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/wtl/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/wtl/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/