Jump to content
Anders Melander

TScrollBar PageSize & Max

Recommended Posts

Is it a known problem that the VCL misinterprets the valid range of TScrollBar's PageSize and Max properties?

 

TScrollBar enforces the rule that PageSize must be <= Max but Windows requires that PageSize be <= Max-Min+1...

This means that if one sets PageSize=Max it is still possible to move the scrollbar +/-1 unit.

 

One work around seems to be to set Min to 1 - because TScrollBar forgets to take Min into account when validating PageSize 🤦‍♂️

 

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setscrollinfo

Quote

The nPage member must specify a value from 0 to nMax - nMin +1.

 

Share this post


Link to post

I did a lot of trial and error while working on the scrollbars for SynEdit and setting min to 1 seemed necessary.  The code I ended up with is in SynEditScrollBars.   The official documentation did seem a bit off in some cases.

 

-Mark

 

Share this post


Link to post

I think the MS documentation, while a bit terse, is clear enough; It specifies how the different properties and their limits relate to each other.

The Delphi documentation though is severely lacking. If they had tried to document it properly they would probably have discovered that they got it wrong.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×