Solved

CSliderCtrl Logic question

Posted on 2009-04-09
1
642 Views
Last Modified: 2013-11-20
Hello,
I have a qustion about the logik to work with a CSliderCtrl on the HScroll event. I have a mp3 player where i use the slider for position in track.Moving the slider currently work well. But I also want that a click on the thumbtrack (the line, not the moveable button) will change the position of the Track and of the thumbbutton (moveable button).

My logik looks currently like in the code section. What I have to change so the position will changed if I click on the line (kumps to this position) and move the thumbbutton?
The Event m_hScrollEvent is setted to avoid incoming position events from the player.

Thanks,
Ocrana


void CPlayerPart2::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)

{

	bool bRes;
 

 if (pScrollBar->GetSafeHwnd() == GetDlgItem(IDC_SLIDER_SONG)->GetSafeHwnd())

	{

		if (SB_THUMBTRACK == nSBCode)

		{

			SetEvent(m_hScrollEvent);

		}

		else if (SB_ENDSCROLL == nSBCode)

		{

			ResetEvent(m_hScrollEvent);

		}

		else if (SB_THUMBPOSITION == nSBCode)

		{

			bRes = Mp3Lib::SeekPlayFile(nPos) ? true : false;

		}

	}

	else

	{

		CBDialog::OnHScroll(nSBCode, nPos, pScrollBar);

	}

}

Open in new window

0
Comment
Question by:Ocrana
1 Comment
 
LVL 49

Accepted Solution

by:
DanRollins earned 500 total points
ID: 24112686
When the user clicks on the track, you will get an SB_PAGERIGHT or SB_PAGELEFT notif.  That's because clicking there is understood to be a request to jump forward or backward by one page (as with a normal scrollbar).
After this, you will get an SB_ENDSCROLL.  I believe that (short of subclassing the slider) you best bet would be to obtain the mouse position at the time of the click
   GetCursorPos Function
   http://msdn.microsoft.com/en-us/library/ms648390(VS.85).aspx
You would then need to convert to client coordinates to figure out where, on the track. the click occurred and use the SetPos function of CSliderCtrl) to move the thumb to that position.  Then you would take whatever action was intended by the user.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Shell script to login to remote m/c and execute commands 10 78
bigDiff challenge 17 84
MaxSpan challenge 9 82
"Black Box" Testing of Control System Software 2 26
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now