Solved

Vertical scrolling.

Posted on 2001-06-05
7
288 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
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 63
Smart Camera scanning and reading information 3 114
changeXy challenge 13 89
Problem to App 4 99
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

821 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