Solved

Vertical scrolling.

Posted on 2001-06-05
Medium Priority
295 Views
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?
0
Question by:eyala
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 1

Expert Comment

ID: 6156814
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
0

LVL 1

Expert Comment

ID: 6157475
Use GetScrollPos in CWnd::OnHScroll to get a 32-bit position.
0

LVL 1

Expert Comment

ID: 6157480
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));
0

LVL 1

Expert Comment

ID: 6157482
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));
0

Author Comment

ID: 6158742
This only increase my range to 32767 * 2. I need much largr range than that. Is it possible?
0

LVL 3

Accepted Solution

GlennDean earned 600 total points
ID: 6159284
To get the full 32-bit scroll position you have to use the GetScrollInfo function!
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
GetScrollInfo(hwnd,SB_VERT,&si);
//Get the 32-bit scroll postion
int nPos = si.nPos;
0

Author Comment

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

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

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  Iâ€™ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductioâ€¦
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonstâ€¦
Suggested Courses
Course of the Month10 days, 8 hours left to enroll