Hittest on trackBar - to set pointer to clicked position

  • Thread starter Thread starter Piotrekk
  • Start date Start date
P

Piotrekk

Hi.
I have a trackbar. I need to set trackbar value depending on where
user has clicked on the bar ( mouse_up event for example ). However
avent arguments are telling me only about x and y position and so
on... If i had hittest method i could try to work it out... Maybe you
will know how to do described task?
Regards
PK
 
Piotrekk,

You should be able to call SendMessage through the P/Invoke layer,
passing the TBM_GETPTICS message. From there, you will have the locations
of all the tics, and you can then calculate your location with the x
position (the y position shouldn't matter, unless this was a vertical
trackbar, in which case the returned array of tics would be compared to the
y value).

You will, of course, have to use the Marshal class to marshal the array
into managed code to do your comparisons.
 
You should be able to call SendMessage through the P/Invoke layer,
passing the TBM_GETPTICS message. From there, you will have the locations
of all the tics, and you can then calculate your location with the x
position (the y position shouldn't matter, unless this was a vertical
trackbar, in which case the returned array of tics would be compared to the
y value).

You will, of course, have to use the Marshal class to marshal the array
into managed code to do your comparisons.

Looks complicated but i will give it a shot.
Thanks
 
Back
Top