JohnLM 27 Posted 14 hours ago (edited) I was wondering if there is a trackbar with two sliders, so that I can use as a min/max setting--i.e., for making text selection ranges. I am not qualified to extend upon the built-in version that comes with Delphi, let alone build one from scratch as a new component. 1st method: I have often come into idea situations with I wish Delphi has one. Today, I had an idea about creating a string utility app to parse strings with (integer) parameters and thought that entering numbers would be a tad bit tedious and then I came up with a trackbar idea, where I build a list of start/end or min/max range and have the app give me the actual position and length position(s) for their values for the string "ABC 123 DEF 456 7GH8 IJKL9". And, given the TrackBarEx below: with the following parameters: TrackBarEx(min=5, max=3) and using those two values, calculate the string to be "123". The trackbarex would return two values, the starting and ending position for the string, per user control. The above is a crude way of explaining what I am trying to do. It may not be as clear or accurate. I would have to calculate the position and distance in the string to get the values of the string position(s) and put those values in a list for me to parse out the string bits. Thus, the following layout of the string, using the trackbarex, I would parse out each of the six text string positions in a list: 1 2 3 123456789012345678901234567890 ABC 123 DEF 456 7GH8 IJKL9 and the returned values would be: 1, 3 ABC 5, 7 123 9,11 DEF 13,15 456 17,20 7GH8 22,26 IJKL9 NOTE: in the above example, the strings "ABC" through "IJKL9" would not be returned. I am just showing that for visual/aesthetics purposes. The trackbarex would contain two sliders and have a minval and maxval that are returned. Not that they are returned but that they are the values of each of the sliders as the user moves them. I would just take those two values and use those to calculate the position within the string. 2nd/alternate method: For now, I have an other method that I am working on right now in hopes to produce the same idea by using one standard TrackBar and a SpinEdit and I would manually set the length of the string to capture every time I move the trackbar to a position. Thus, move trackbar to position 1, set the spinedit to 3, calculate the string and parse it to "ABC". Rinse and repeat for "123", thus move trackbar to position 5, set the spinedit to 3, calculate the string and parse it to "123".., rinse and repeat, . . . and so on. Edited 14 hours ago by JohnLM typos and corrections Share this post Link to post
Remy Lebeau 1573 Posted 14 hours ago 8 minutes ago, JohnLM said: I was wondering if there is a trackbar with two slider Not natively, no. But I'm sure a 3rd party one exists if you search around. Share this post Link to post
JohnLM 27 Posted 14 hours ago I just made some edits to the topic. I did not complete this post. I pressed the [submit] button too quicky. Anyway. In the 2nd method, I have the trackbar and spinedit controls. And below that, I have an editbox also, and below that, two memo's, one for the the strings and another for the value pairs to use in parsing out the strings. And then, I have [Add] and [Del] buttons. I am designing the app to show in real-time, the text I am selecting via the trackbar and spinedit so that I can see the values I need. The real-time feedback will help to show me what I am selecting. If I can get a working demo, I will post it up here. It might be useful in some way or idea for others. Share this post Link to post
Squall_FF8 1 Posted 4 hours ago (edited) Judging by the explanation, I would suggest that your design (using what component for what) is wrong! 1st Method: you want to use two thumbs on one track. The values that each thumb represent are the values that track represent. So first is Position - that is fine. But second is Length - it has nothing to do with the track (which represent position in the text). Your picture would make sense if the two thumbs are Start/End position. 2ndMethod. Using TrackBar in general is inaccurate - most likely you cant get with the thumb, all values that you need. The larger is the set that you want to represent, the higher probability is. The reason for that is the rounding error between thumb position on screen and resulting set. If the set has more elements then the length of the bar (in pixels) you will have 100% inaccuracy. SpinEdit on other hand is 100% accurate - with keyboard or mouse you can get all values that you need. So I would suggest to use 2nd Method with changing controls - use SpinEdit for Position in text (since text could be HUGE) and Trackbar for Length. P.S. I'm not sure about latest iterations of Delphi (10+) but in the past RxSpinEdit had some nice tricks with mouse (compared to stock SpinEdit). Edited 3 hours ago by Squall_FF8 Share this post Link to post
Anders Melander 1974 Posted 2 hours ago The PegTop track and range bars are quite nice and easy to use: https://www.pegtop.net/delphi/components/common/screenshots.htm ...and there's couple in the SO post: https://stackoverflow.com/questions/4387690/component-similar-to-trackbar-to-enter-a-range-of-values ...and if you can wait a week or so I will be releasing one of my own (based on Graphics32 though). I have the track bar part completed so I'm starting on the range bar part now. DevExpress also has a range bar and I believe TMS has one too. Personally, if I weren't writing my own 🙂, I would go for the PegTop range bar; I have used it with success in many projects. 1 Share this post Link to post