Scrollbar.LargeChange and Maximum

Discussion in 'Questions (Windows Mobile)' started by BjornF, Sep 22, 2008.

  1. BjornF

    BjornF Active Member Licensed User

    Not sure whether this is a bug or not.

    I have a question concerning scrollbar.maximum and scrollbar.largechange. If you run the code below the maximum value you can get is actually 15 and not 20 (which is the value it is set at). If you set Largechange to 3 the maximum attainable is 17. It seems as if the maximum value attainable is actually scrollbar.maximum-scrollbar.largechange. Is this by design or a bug?
    If I am correct ;) I think it deserves to be mentioned in the help file anyway.

    all the best / Björn

    Sub Globals
    'Declare the global variables here.

    End Sub

    Sub App_Start
    End Sub

    Sub FillTable
    For i=0 To 19
    End Sub

    Sub scrollbar_valuechanged
    End Sub
  2. agraham

    agraham Expert Licensed User

    You are nearly right! The maximum value seems to be "scrollbar.maximum-scrollbar.largechange+1".

    I had not noticed this before as I don't do a lot of user interface stuff and when I have used scrollbars I have just left the largechange as the default of 1.

    I think this is by design. Note that setting largechange affects the size of the thumb in the scrollbar. If you imagine that you are looking at a long document with a vertical scrollbar then largechange would be set to a value that scrolls a visible page so the size of the thumb will represent the proportion of the document that is visible and position of the top of the thumb will represent the location in the document of the top of the visible page. This is also the maximum value of the scrollbar.

    To put it another way "scrollbar.value/scrollbar.maximum" is the fractional position in the document at which to start drawing the visible page. When the value is "scrollbar.maximum-scrollbar.largechange+1" the end of the document would be just visible on the page.
    Last edited: Sep 22, 2008
  3. BjornF

    BjornF Active Member Licensed User

    Dear Graham,

    yes, of course it is +1, sorry I wasn't thinking clearly.

    I can follow the logic of why it is constructed this way. It is just that to my somewhat inflexible way of thinking if you give a maximum value of a control then that should be the maximum-level attainable, irrespective of the size of e.g. LargeChange :(

    But I suppose that there are conventions that one will just has to live with :)
  4. klaus

    klaus Expert Licensed User


    I had also some concerns about the ScrollBar.Maximum and ScrollBar.LargeChange problem.
    In some cases ScrollBar.Maximum had to be ScrollBar.Maximum = MaxValue
    In an other case ScrollBar.Maximum = MaxValue - ScrollBar.LargeChange + 1

    So I had a closer look at the ScrollBar.Maximum and ScrollBar.LargeChange problem.

    It is somewhat more complicated and depends on the length of the displayed part of the 'document' and the LargeChange value.

    I have written a small program to illustrate the relationships.

    In the upper part I only put a ScrollBar with Min = 0 Max = 100 ScrollBar.LargeChange = 20
    In this case ScrollBar.Maximum = 100 !
    If you slide the cursor to the maximum the ScrollBar.Value becomes Max - ScrollBar.LargeChange + 1 = 81

    In the middle part with a ruler bitmap display, width bmpW = 1201 pixel. In this case the ScrollBar.LargeChange is allways equal to the width of the displayed screen. And ScrollBar.Maximum = MaxValue = 1200
    1201 is the number of pixels, 1200 is the last pixel position counting from 0 ! ! !

    In the lower part, the screen display is GraphW = 200 pixels wide, the ScrollBar.LargeChange = 100, this is half of the display width.
    In that case, ScrollBar.Maximum = 1201 - ScrollBar.LargeChange = 1101
    or ScrollBar.Maximum = 1200 - ScrollBar.LargeChange +1 = 1101
    Once again, 1201 is the number of pixels, 1200 is the last pixel position counting from 0 ! ! !

    If we put ScrollBar.LargeChange = 50, and slide the cursor at the end, the displayed ruler is wrong !

    The ScrollBar.Maximum value, in this case, must be: (check the CheckBox)
    ScrollBar.Maximum = bmpW - 1 - GraphW + ScrollBar.LargeChange
    this is the general case if ScrollBar.LargeChange < GraphW. For, if ScrollBar.LargeChange = GraphW then ScrollBar.Maximum = bmpW - 1 ? !

    In all cases, in the lower part, the maximum value of the ScrollBar.Value = 1001, this is the max value - display width, or bmpW - GraphW = 1201 - 200 = 1001.

    For me there is a strange behaviour, because in my mind, as it is in Visual Basic, ScrollBar.Maximum should be the max value for ScrollBar.Value.

    In the example in the middle part, if you enter ScrollBar.Value = 1150, which is higher than the max value of 1101 when sliding the cursor to the right end, it is accepted but the display is wrong. If you enter ScrollBar.Value = 1201 which is higher than ScrollBar.Maximum, an error is generated.

    Erel, is this different behaviour in B4PPC, according to VB, due to .NET or due to B4PPC ?

    I hope my post is understandable.

    Best regards.

    Attached Files:

  5. Erel

    Erel Administrator Staff Member Licensed User

    The ControlsEx library is only a wrapper above .net controls and it doesn't alter their behavior.
  6. klaus

    klaus Expert Licensed User

    Thank you for the answer.

    I tried the same with VB 2005, and the behaviour is the same as with B4PPC.

    Microsoft seems having changed the behaviour between VB6 and VB.Net.

    Best regards.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice