Once in a while I need a GUI to set numeric ranges, but so far I've never really found any component that does it nicely.
I've attempted the following:
2 TTrackbars: 1 for min, 1 for max
2 TTackbars: 1 for min, 1 for range
2 TSpinEdit controls to type the numbers manually
1 TTrackbar control, with a little button to switch between min-mode and max-mode. In min-mode I set selStart and in max-mode I set selEnd (with ShowSelRange set to true).
Most options take more screen estate than I'd like, and they are not intuitive.
Ideally, I'd like something that works like the scrollbar in Sony ACID. You can click and drag 3 different points to the min, max, or both:
Is there any Free component available to set a range, or can something similar be done by using out-of-the-box VCL components creatively?
I've modified TMkRangeSlider to suit my needs. It works like a charm now. I've sent the modified component and demo to the original author.
How about something like Range Slider, by Michael Kochiashvili. It is freeware with source, written for Delphi 5 and comes with a demo:
It won't move min and max simultaneously, but since you've got the source, you could probably add that functionality if you really need it.
Using a standard TScrollBox, it is technically possible to do some manual fiddling of its PageSize and Position properties while dragging its thumb around (ScrollCode=scTrack in its OnScroll event) to simulate the kind of UI that you showed in the ACID screenshot. The problem is that 1) you can't owner-draw a TScrollBar to add the drag lines, and 2) there is no direct way to determine which portion of the thumb the user is holding the mouse down on (the ends versus the middle). Unless you can come up with some fairly reliable calculations to figure out the pixel offsets of the left and right edges of the thumb based on the current Position and PageSize in relation to the overall client rectangle, then you are probably best off simply writing your own component instead, and then you can make it look and behave anyway you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With