• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1466
  • Last Modified:

CSliderCtrl caluclate Mouse click to Position

Hello,

I want to save in a csliderctrl a extended GetPos. This GetPosEx() will return the real position inside a trackbar of a CSliderCtrl.  To Set this I want to do this inside the OnLButtonClick where I have only the position of the mouselick. How to calculate the real position/value of the slider at this position. My Slider has 0-100 value.

Ocrana
0
Ocrana
Asked:
Ocrana
1 Solution
 
StefanKittelCommented:
Hello,

I'm not sure I got everything.
You wan't to calucalte the position of your silder from the absolut mouse position?

OK.
You got the mouse position
You need the top left position from your slider using GetWindowPos
You need the size from your slider using GetWindowPos
I'm not sure how to get the size of the knobs left and right. I'll use them as consts and get the size by a screenshot.

pos = mouse pox X * ((right - left - (2 * knob)) / 100)

Stefan
0
 
DanRollinsCommented:
The specific answer depends on how you obtain the position of the mouse pointer.  The calculations will be different depending on if the location is expressed in screen-global or client-local coordinates.
0
 
OcranaAuthor Commented:
No finaly what I needed but helps me alot.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Tackle projects and never again get stuck behind a technical roadblock.
Join Now