Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Scrollbar.LargeChange and Maximum

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-22-2008, 08:41 AM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 173
Default Scrollbar.LargeChange and Maximum

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



Code:
Sub Globals
    
'Declare the global variables here.

End Sub

Sub App_Start
    Form1.Show
    FillTable
    scrollbar.New1(
"Form1",5,form1.Height-30,form1.Width-10,20,False)
    scrollbar.Minimum=
0
    scrollbar.Maximum=table1.RowCount-
1
    scrollbar.SmallChange=
1
    scrollbar.LargeChange=
5
End Sub


Sub FillTable
    table1.AddCol(cString,
"Col1",50)
    
For i=0 To 19
        table1.AddRow(i)
    
Next
End Sub

Sub scrollbar_valuechanged
    label1.Text=scrollbar.Value
End Sub
Reply With Quote
  #2 (permalink)  
Old 09-22-2008, 09:25 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by BjornF View Post
It seems as if the maximum value attainable is actually scrollbar.maximum-scrollbar.largechange.
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 by agraham : 09-22-2008 at 09:31 AM.
Reply With Quote
  #3 (permalink)  
Old 09-22-2008, 09:58 AM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 173
Default

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
Reply With Quote
  #4 (permalink)  
Old 09-27-2008, 09:57 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hello,

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 Images
File Type: jpg ScrollBar.jpg (18.6 KB, 28 views)
Attached Files
File Type: zip ScrollBar.zip (13.2 KB, 22 views)
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #5 (permalink)  
Old 09-28-2008, 04:01 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Quote:
Erel, is this different behaviour in B4PPC, according to VB, due to .NET or due to B4PPC ?
The ControlsEx library is only a wrapper above .net controls and it doesn't alter their behavior.
Reply With Quote
  #6 (permalink)  
Old 09-29-2008, 07:06 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

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.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to set a width of the scrollbar? aeror Questions (Windows Mobile) 2 06-19-2008 10:22 AM
Scrollbar aerohost Basic4ppc Wishlist 1 06-15-2008 02:56 PM
Scrollbar on a Panel willisgt Questions (Windows Mobile) 5 03-10-2008 08:12 PM
Rnd() ignores the maximum value Mistrel Questions (Windows Mobile) 6 10-15-2007 03:15 PM
HTTP maximum request size and method problems willisgt Questions (Windows Mobile) 1 08-27-2007 07:10 PM


All times are GMT. The time now is 02:24 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0