Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CSliderCtrl caluclate Mouse click to Position

Posted on 2009-04-11
3
Medium Priority
?
1,438 Views
Last Modified: 2013-11-20
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
Comment
Question by:Ocrana
3 Comments
 
LVL 4

Accepted Solution

by:
StefanKittel earned 2000 total points
ID: 24126996
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 24132967
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
 

Author Closing Comment

by:Ocrana
ID: 31569235
No finaly what I needed but helps me alot.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question