Link to home
Start Free TrialLog in
Avatar of eyala
eyala

asked on

Vertical scrolling.

One of the parameters of CWnd::OnHScroll is nPos which Specifies the scroll-box position. In my application, the range that the scroller can be changed is very large. It can get over 100,000. The problem is that nPos is defined as UINT. In such cases, when I drag the slider over the 32,768 position, the nPos get garbage values.
Is there any way to overcome this annoying behaviour?
Avatar of AndreasF
AndreasF

As far as I know you can only set the range to the maximum possible and recalculate nPos with an algorithm like
nActualPosition = (nPos/32768)*100000;

Greetings
Andi
Use GetScrollPos in CWnd::OnHScroll to get a 32-bit position.
If you want to use the nPos, you can get the actual position by :
if(((int)nPos) < 0)      // nPos < 0 if over 32767
     x = 32767+(32767-((int)nPos));  
If you want to use the nPos, you can get the actual position by :
if(((int)nPos) < 0)      // nPos < 0 if over 32767
     nPos = 32767+(32767-((int)nPos));  
Avatar of eyala

ASKER

This only increase my range to 32767 * 2. I need much largr range than that. Is it possible?
ASKER CERTIFIED SOLUTION
Avatar of GlennDean
GlennDean

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eyala

ASKER

thanks, you showed me the way, but I think more accurate way to do it is like this:

SCROLLINFO si;
si.fMask = SIF_ALL;
GetScrollInfo(SB_HORZ, &si);
nPos = si.nTrackPos;