Results 1 to 10 of 10

Thread: [RESOLVED] Limits GetScrollInfo

  1. #1

    Thread Starter
    Hyperactive Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    344

    Resolved [RESOLVED] Limits GetScrollInfo

    Code:
    Private Type SCROLLINFO
         cbSize As Long
         fMask As Long
         nMin As Long
         nMax As Long
         nPage As Long
         nPos As Long
         nTrackPos As Long
    End Type
    
    Private Declare Function GetScrollInfo Lib "user32" (ByVal Hwnd As Long, ByVal nBar As Long, ByRef si As SCROLLINFO) As Long
    Private Declare Function SetScrollInfo Lib "user32" (ByVal Hwnd As Long, ByVal nBar As Long, ByRef si As SCROLLINFO, ByVal bRedraw As Boolean) As Long

    All GetScrollInfo API return items are marked LONG. However, in an RTB there is a text that has approximately 100 pages (Measures in Word).
    When using GetScrollInfo nMax returns approximate values of 65534 .... sometimes if I increase the text (copy and paste several times), nMax will increase only a little.

    I thought it should return a LONG value instead of just values close to 65534...

  2. #2
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    414

    Re: Limits GetScrollInfo

    Quote Originally Posted by Episcopal View Post
    Code:
    Private Type SCROLLINFO
         cbSize As Long
         fMask As Long
         nMin As Long
         nMax As Long
         nPage As Long
         nPos As Long
         nTrackPos As Long
    End Type
    
    Private Declare Function GetScrollInfo Lib "user32" (ByVal Hwnd As Long, ByVal nBar As Long, ByRef si As SCROLLINFO) As Long
    Private Declare Function SetScrollInfo Lib "user32" (ByVal Hwnd As Long, ByVal nBar As Long, ByRef si As SCROLLINFO, ByVal bRedraw As Boolean) As Long

    All GetScrollInfo API return items are marked LONG. However, in an RTB there is a text that has approximately 100 pages (Measures in Word).
    When using GetScrollInfo nMax returns approximate values of 65534 .... sometimes if I increase the text (copy and paste several times), nMax will increase only a little.

    I thought it should return a LONG value instead of just values close to 65534...
    I'm no scroll api expert, but it would seem that the typing to LONG here is not an indication to expect that the function itself will return beyond a certain value.

    According to MS.com this SCROLLINFO structure could just as easily been passed with nMax as Int.

    https://docs.microsoft.com/en-us/win...ser-scrollinfo

    Just a thought.

  3. #3

    Thread Starter
    Hyperactive Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    344

    Re: Limits GetScrollInfo

    If I use "Integer", then I'm limiting myself to 32,767...

    My thought.

    Edit: thanks for answering

  4. #4
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    414

    Re: Limits GetScrollInfo

    Quote Originally Posted by Episcopal View Post
    If I use "Integer", then I'm limiting myself to 32,767...

    My thought.

    Edit: thanks for answering
    I get that. I was just saying the struc def appears to suggest a limit.

    Anyway, are you sure you have over 65K lines of text, or are you counting individual characters?

    You mentioned 100 Word pages. An average number of lines per Word page is around 46 at 12 point.

    So you would have 4600 lines, not 65K.

    Perhaps that's where you are getting hung up?

    Adding more text without getting close to the nMax value should not change the nMax.

    As for a LIMIT, I came across some information where a test was ran.

    "I ran some tests, and found that nMax is
    capped at the maximum 16-bit value 0xffff, and nPos is scaled into this
    range."



    :-)
    Last edited by webbiz; Feb 3rd, 2022 at 05:22 PM.

  5. #5

    Thread Starter
    Hyperactive Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    344

    Re: Limits GetScrollInfo

    What I'm baffled about is that I enter, let's say a thousand pages, but the return value of nMax doesn't change much even if I enter more text.

  6. #6
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    414

    Re: Limits GetScrollInfo

    Quote Originally Posted by Episcopal View Post
    What I'm baffled about is that I enter, let's say a thousand pages, but the return value of nMax doesn't change much even if I enter more text.
    LOL! Could it be that nMax is...at the max? ;-)

  7. #7
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,097

    Re: Limits GetScrollInfo

    Have you checked the nPage, nPos, nTrackPos values?

  8. #8

    Thread Starter
    Hyperactive Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    344

    Re: Limits GetScrollInfo

    Quote Originally Posted by webbiz View Post
    LOL! Could it be that nMax is...at the max? ;-)
    My doubt is doubted by many ... from what I researched .... my friend.

  9. #9

    Thread Starter
    Hyperactive Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    344

    Re: Limits GetScrollInfo

    Quote Originally Posted by Arnoutdv View Post
    Have you checked the nPage, nPos, nTrackPos values?
    Yes ... Arnoutdv ...
    Attached Images Attached Images  

  10. #10

    Thread Starter
    Hyperactive Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    344

    Re: Limits GetScrollInfo

    Indeed, this is the maximum value, regardless of the text content.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width