Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GUI to set numeric ranges in Delphi

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

  • ttrackbar with range 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:

Awesome mspaint drawing

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?


Update

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.

TMkRangeSlider 1.1

like image 631
Wouter van Nifterick Avatar asked Aug 14 '09 23:08

Wouter van Nifterick


2 Answers

How about something like Range Slider, by Michael Kochiashvili. It is freeware with source, written for Delphi 5 and comes with a demo:

alt text

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.

like image 76
lkessler Avatar answered Sep 29 '22 22:09

lkessler


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.

like image 25
Remy Lebeau Avatar answered Sep 29 '22 22:09

Remy Lebeau