Original Post
Hello, Recently, I am developing some application. When it came to implement OnMouseWheel function I came accros this problem. Here is the code:
// get scrollbar info
si.cbSize = sizeof( SCROLLINFO );
si.fMask = SIF_ALL;
GetScrollInfo( SB_VERT, &si );
// get change ration
si.fMask = SIF_POS;
// THIS IS THE LINE WHICH PRODUCES THE WRONG RESULT!!!
si.nPos -= ( zDelta/WHEEL_DELTA )*si.nPage/2;
SetScrollInfo( SB_VERT, &si, TRUE );
When: zDelta = -120 WHEEL_DELTA = 120 si.nPage = 263 I got result = -2147483516 but when I change that line into: si.nPos -= ( zDelta/WHEEL_DELTA )*( si.nPage/2 ); everything is ok. Why is it so ? I guess there is sth to do with arithmetic operator priorites, Am I right ? Thx