Solved

Vertical scrolling.

Posted on 2001-06-05
7
289 Views
Last Modified: 2013-11-20
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
Comment
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
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:AndreasF
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

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

Expert Comment

by:guoching
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:guoching
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

by:eyala
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

by:
GlennDean earned 200 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);
si.fMask = SIF_RANGE;
GetScrollInfo(hwnd,SB_VERT,&si);
//Get the 32-bit scroll postion
int nPos = si.nPos;
0
 

Author Comment

by:eyala
ID: 6159761
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;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question