I've never done it, but I would start by looking at the location of the mouse click. I could then figure out how far across the current extent of the trackbar the click was located and set the tracker's location to that spot.
I'd start by looking into overriding the control and manipulating the Mouse-related event functions (OnMouseDown()
, e.g.). Note that in some cases it may be important to call the base class' implementation of an overridden function, be sure to consider it on a case-by-case basis. (I just ran afoul of this, so it's fresh in my mind.)
Note that you should only change the behavior of standard controls in this manner if you have a very compelling reason. They're standard because they behave in a predictable way across many hundreds/thousands of programs. Making something behave differently for just your program can violate the Principle of Lease Astonishment. The only trackbar I can think of that I expect to behave the way you describe is for some sort of media player.
Edit:
Based on your comment, yeah, I think you've got a compelling reason. :)