ownerdraw rangemarkers

The place for threads about TimoSoft TrackBar.
Post Reply
ijwelch
Cadet
Posts: 1
Joined: 07 Oct 2009, 16:44

ownerdraw rangemarkers

Post by ijwelch » 07 Oct 2009, 17:18

Hi. Thanks for the free controls. They're great.

I'm trying to implement a trackbar with range selection and owner drawing. I've managed to do everything I absolutely need but had to jump through a few hoops to do it. I thought I'd post my wishlist so you know what is missing or is unnecessarily difficult in the current version.

1. There doesn't seem to be a way to owner draw the rangestart/end markers. Can this be added? Or is there a way? - The default markers are just too small

2. Can we have functions to calculate the x/y coordinate from a logical value and vice versa. For example, I'm ownerdrawing and need to draw the rangeselection - i can't see a built-in way to get the start and end x pixel coordinates (for a horizontal trackbar) for the rangeselectionstart and rangeselectionend values.

3. Here's a few of things I just had to implement myself by subclassing. These are probably outside the scope of your project but you may be interested in implementing them:
a) LMousedown behaviour on track. I needed to have value set to mouse x position, i.e. no large-scrolling - just immediate value set to nearest value for mouse position.
b) Repeated clicking LMouse button at the same position toggles value between nearest logical values above and below. I needed to stop that behaviour and just have value set to nearest logical value for mouse position.
c) If Shift key held down then LeftMousedown sets RangeSelectionStart value, RightMouseDown sets RangeSelectionEnd value. Same for mousemove (if shift+lbuttondown or shift+rbuttondown).

4. I can't find a way to lose the focus rectangle from the entire control. This looks like a MS thing but thought it worth mentioning.


Anyway, I worked around all of this apart from 1. and 4. which are minor things. This was after trying many other components and finding them all lacking in some showstopping way.

User avatar
TiKu
Administrator
Administrator
Posts: 823
Joined: 28 Sep 2004, 21:10
Location: Unterföhring
Contact:

Re: ownerdraw rangemarkers

Post by TiKu » 07 Oct 2009, 23:33

Thanks for your feedback.
ijwelch wrote:1. There doesn't seem to be a way to owner draw the rangestart/end markers. Can this be added?
I doubt it. My control is a COM wrapper around the native track bar control of Windows. This native control doesn't provide a way to customize the range markers and I cannot think of an elegant way to work around this limitation.
ijwelch wrote:2. Can we have functions to calculate the x/y coordinate from a logical value and vice versa. For example, I'm ownerdrawing and need to draw the rangeselection - i can't see a built-in way to get the start and end x pixel coordinates (for a horizontal trackbar) for the rangeselectionstart and rangeselectionend values.
I'll check whether this can be done.
ijwelch wrote:3. Here's a few of things I just had to implement myself by subclassing. These are probably outside the scope of your project but you may be interested in implementing them:
a) LMousedown behaviour on track. I needed to have value set to mouse x position, i.e. no large-scrolling - just immediate value set to nearest value for mouse position.
b) Repeated clicking LMouse button at the same position toggles value between nearest logical values above and below. I needed to stop that behaviour and just have value set to nearest logical value for mouse position.
c) If Shift key held down then LeftMousedown sets RangeSelectionStart value, RightMouseDown sets RangeSelectionEnd value. Same for mousemove (if shift+lbuttondown or shift+rbuttondown).
Well, that's the way the native control works. I'm a bit reluctant to implement features that are not supported by the native controls, because I often did so in the past and ran into trouble when new versions of Windows were released. For example, my tree view control had support for a background image and multi-selection. It already was a mess to support this stuff for Windows XP and earlier. Then came Vista and I tried to make these features compatible with Vista for several months - without success. In the end I removed both features completely, because I realized that they caused way too many problems and that these extra features are of no use, if the control has too many bugs to be used in production code.
ijwelch wrote:4. I can't find a way to lose the focus rectangle from the entire control. This looks like a MS thing but thought it worth mentioning.
You shouldn't just remove the focus rectangle. This is poor design. The user should get some visual feedback telling him which control has the focus - at least if he uses the keyboard to interact with the GUI.
Windows has implemented a good compromise: Keyboard and focus cues are hidden until the user starts using the keyboard for GUI interaction (pressing the TAB key to navigate between controls or pressing ALT to trigger commands by keyboard shortcuts). This mechanism doesn't work well with VB6, that's why VB6 apps often display focus rectangles when they shouldn't and vice versa. By using a keyboard hook, it's possible to improve support for the keyboard and focus cues from a VB6 app.
I'm not sure it will work for the track bar's focus rectangle, but if you want to give it a try, have a look at the samples that come with my ButtonControls lib. They use a keyboard hook and the WM_CHANGEUISTATE message to improve support for the keyboard and focus cues.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

Post Reply