Wouter van Nifterick
Wouter van Nifterick

Reputation: 24096

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:

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

Upvotes: 6

Views: 1119

Answers (2)

lkessler
lkessler

Reputation: 20132

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.

Upvotes: 5

Remy Lebeau
Remy Lebeau

Reputation: 596387

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.

Upvotes: 1

Related Questions