CScrollbar Question  
Author Message
Vasic





PostPosted: Visual C++ Language, CScrollbar Question Top

I'm trying to find out where the scroll box is while it's being dragged. When I do a TRACE() using GetScrollPos() it returns the starting position. How do I get ahold of the position while I'm scrolling

Visual C++11  
 
 
kuphryn





PostPosted: Visual C++ Language, CScrollbar Question Top

tracking mouse motion

Kuphryn


 
 
Vasic





PostPosted: Visual C++ Language, CScrollbar Question Top

So there isn't an MFC message in OnVScroll() I can use
 
 
Vasic





PostPosted: Visual C++ Language, CScrollbar Question Top

Sorry guys, yet again I answered my own stupid question. Evidently one of the parameters of OnVScroll() is nPos. This variable contains the updated box position. GetScrollPos() doesn't update it's position until you release the box. Sorry again... I'll try to come up with better questions in the future :(
 
 
Vasic





PostPosted: Visual C++ Language, CScrollbar Question Top

Ok well I got some scrolling positions coming out in my trace.  I'm wondering why the nPos isn't updating with the correct position.  It's scrolling between the max and min in negative and positive integers as so:

Position = 0

Position = 3593

Position = 4790

Position = 9580

Position = 14371

Position = 19161

Position = 26346

Position = 32334

Position = -27214

Position = -21226

Position = -17634

Position = -11646

Position = -5658

Position = 330

Position = 5120

Position = 11108

Position = 17096

Position = 21886

Position = 27874

Position = -31675

Position = -23292

Position = -14909

Position = -5328

Position = 4252

Position = 17425

Position = 29401

Position = -22962

Position = -9789

Position = 4582

Position = 18953

Position = 24940

Position = -25027

Position = -10657

Position = 3714

Position = 18085

Position = 32456

Position = -16315

Position = -1944

Position = 12427

Position = 27995

Position = -24368

Position = -12392

Position = -2812

Position = 1979

Position = 16349

Position = 30720

Position = -18050

Position = -4877

Position = 4703

Position = 10691

Position = 20272

Position = 29852

Position = -24906

Position = -16523

Position = -6942

Position = 243

Position = 6231

Position = 11021

Position = 17009

Position = 20601

Position = 24194

Position = 26589

Position = 27787

Position = 30182

Position = -31761

Position = -28169

Position = -26971

Position = -24576

THUMBPOSITION

END SCROLL

The above is me taking the box from the top to the bottom.  This is the nPos parameter in OnVScroll().  The min is 0 and the max is 565248.  Hope there is an easy way to do this =]


 
 
Martin Richter





PostPosted: Visual C++ Language, CScrollbar Question Top

The problem is that nPos in OnVScroll is a 16bit value. If you scroll positions are larger than you can't rely on the argument. You need to use GetScrollbarInfo, with this function you can get the true 32bit position of the scrollbar!

 
 
Vasic





PostPosted: Visual C++ Language, CScrollbar Question Top

Thanks a bunch Martin!!