Recent

Author Topic: Windows: Finding the position of the horizontal scroll bar in a TScrollbox  (Read 1970 times)

zxandris

  • Full Member
  • ***
  • Posts: 170
I'm making something that browses an image and when the image isn't sized the screen I want to scroll to the bottom then load the next image. Only I can for the life of me figure out how to detect where the horizontal scroll bar actually is.

Code: Pascal  [Select][+][-]
  1.       if (sbImage.HorzScrollBar.ScrollPos-sbMargin)>=sbImage.HorzScrollBar.Range then
  2.       begin
  3.          actIVNavNextExecute(self);
  4.          handled := true;
  5.       end else
  6.       begin
  7.         Handled := false;
  8.         inherited;
  9.       end;
  10.  

That's my code, but you'd think that scrollpos would hold where the scroll bar gribber actually is, but I've tried getting that and it reports 0 all the time.  Does anyone have a way to do this.  I'm using windows, so that may be important.

CJ

jamie

  • Hero Member
  • *****
  • Posts: 7413
scrolls are always 0 in pos until you move them by code or user.

When they show, they normally show at 0 pos unless you force a child control in view, in this you aren't.

 anything else, please provide more code.

The only true wisdom is knowing you know nothing

zxandris

  • Full Member
  • ***
  • Posts: 170
scrolls are always 0 in pos until you move them by code or user.

When they show, they normally show at 0 pos unless you force a child control in view, in this you aren't.

 anything else, please provide more code.

Well that's the thing I don't have any code, because I don't know what to do to find out where the scroll gipper thing is, I essentially want to know when it's at the bottom, or the top but don't know how to code becuase right now I have ZERO idea how to get that position :).

Maybe there's a window message to read a scroll bar position?  But I wouldn't know the code to do it.  That's kinda what I need help with lol.

jamie

  • Hero Member
  • *****
  • Posts: 7413
I am going to assume that you are drawing directly on the scrollbox and this means you must control the scroll information to get it to show.

 When the POSITION and RANGE match you are at the end.

 you can set the RANGE of the scrollbar that should turn it on, indicating you want it viewed.

 so, if you have an image to draw that is taller than the scrollbox's client, you can set the RANGE to the Image Height - CLientHeight and that will turn it on. The POSITION should match the RANGE when you are at the bottom of the slide.

 Also, one thing to note, if the Horizontal scrollbar is showing, the ClientHeight will be that much smaller.

 Getting the CLientRect reports the visiable area without scrollbars, so it will get smaller when the bars show.

 So, when calculating the Vertical values, the horizontal scrollbar will affect the results.

 Does that help at all ?




The only true wisdom is knowing you know nothing

zxandris

  • Full Member
  • ***
  • Posts: 170
I am going to assume that you are drawing directly on the scrollbox and this means you must control the scroll information to get it to show.

 When the POSITION and RANGE match you are at the end.

 you can set the RANGE of the scrollbar that should turn it on, indicating you want it viewed.

 so, if you have an image to draw that is taller than the scrollbox's client, you can set the RANGE to the Image Height - CLientHeight and that will turn it on. The POSITION should match the RANGE when you are at the bottom of the slide.

 Also, one thing to note, if the Horizontal scrollbar is showing, the ClientHeight will be that much smaller.

 Getting the CLientRect reports the visiable area without scrollbars, so it will get smaller when the bars show.

 So, when calculating the Vertical values, the horizontal scrollbar will affect the results.

 Does that help at all ?

This has helped a lot thank you, I've got what I wanted to work, working, and now I've got fairly continous scrolling, thanks :)

 

TinyPortal © 2005-2018