A slider (non-visual effect) similar to the pause progress bar)

Source: Internet
Author: User

 

 

Bool cplayertestdlg: pretranslatemessage (MSG * PMSG) <br/>{< br/> // todo: add your specialized code here and/or call the base class <br/> cpoint point; <br/> If (PMSG-> message = wm_lbuttondown <br/> & PMSG-> hwnd = getdlgitem (idc_slider)-> getsafehwnd ()) <br/>{< br/> getcursorpos (& Point); <br/> screentoclient (& Point); <br/> onsliderlmousedown (point ); <br/> return true; <br/>}< br/> else if (PMSG-> message = Wm_lbuttonup <br/> & m_sliderleftmousedown = true) <br/> {<br/> getcursorpos (& Point); <br/> screentoclient (& Point ); <br/> onsliderlmouseup (point); <br/> return true; <br/>}< br/> else if (PMSG-> message = wm_mousemove <br/> & m_sliderleftmousedown = true) <br/>{< br/> getcursorpos (& Point); <br/> screentoclient (& Point); <br/> onsliderlmousemove (point ); <br/> return true; <br/>}< br/> return cdialog: pretr Anslatemessage (PMSG); <br/>}< br/> bool cplayertestdlg: onsliderlmousedown (cpoint point) <br/>{< br/> If (! Destroythread () <br/>{< br/> return false; <br/>}< br/>:: setcapture (this. getsafehwnd (); <br/> crect rect; <br/> m_playerslider.getwindowrect (& rect); <br/> screentoclient (& rect); <br/> rect RC; <br/> m_playerslider.getthumbrect (& rc); // the coordinate system for this value is slider <br/> int nthumbleft = RC. left + rect. left; // change to the value in the client Coordinate System <br/> int nthumbright = RC. right + rect. left; <br/> If (point. x> = nthumbleft & Point. x <= nthumbright) <br/>{< br/> m_sliderleftmousedown = true; <br/>}< br/> else <br/>{< br/> int nsliderpos; <br/> nsliderpos = (point. x-rect. left) * <br/> (m_playerslider.getrangemax ()-m_playerslider.getrangemin () <br/>/(rect. right-rect. left) + m_playerslider.getrangemin (); <br/> m_playerslider.setpos (nsliderpos); <br/> setplaypos (m_playerslider.getpos (); <br/>: releasecapture (); <br/> startthread (); <br/>}< br/> return true; <br/>}< br/> bool cplayertestdlg: onsliderlmouseup (cpoint point) <br/>{ <br/> crect rect; <br/> m_playerslider.getwindowrect (& rect); <br/> screentoclient (& rect); <br/> int nsliderpos; <br/> If (point. x <rect. left) <br/>{< br/> nsliderpos = m_playerslider.getrangemin (); <br/>}< br/> else if (point. x> rect. right) <br/>{< br/> nsliderpos = m_playerslider.getrangemax (); <br/>}< br/> else <br/> {<br/> nsliderpos = (point. x-rect. left) * <br/> (m_playerslider.getrangemax ()-m_playerslider.getrangemin () <br/>/(rect. right-rect. left) + trim (); <br/>}< br/> m_playerslider.setpos (nsliderpos); <br/> setplaypos (m_playerslider.getpos (); <br/> m_sliderleftmousedown = false; <br/>: releasecapture (); <br/> startthread (); <br/> return true; <br/>}< br/> bool cplayertestdlg :: onsliderlmousemove (cpoint point) <br/>{< br/> crect rect; <br/> m_playerslider.getwindowrect (& rect); <br/> screentoclient (& rect ); <br/> int nsliderpos; <br/> If (point. x <rect. left) <br/>{< br/> nsliderpos = m_playerslider.getrangemin (); <br/>}< br/> else if (point. x> rect. right) <br/>{< br/> nsliderpos = m_playerslider.getrangemax (); <br/>}< br/> else <br/> {<br/> nsliderpos = (point. x-rect. left) * <br/> (m_playerslider.getrangemax ()-m_playerslider.getrangemin () <br/>/(rect. right-rect. left) + m_playerslider.getrangemin (); <br/>}< br/> m_playerslider.setpos (nsliderpos); <br/> return true; <br/>}

 

Description of the preceding destroythread () and startthread () functions: for real-time scrolling of the progress bar, I created a thread that keeps reading the playback frames, after processing, set the Slider's slider position

Destroythread:

Stop the thread so that the slider does not slide

 

Startthread:

Enable the thread so that the slider can continue sliding in real time

 

Setplaypos ():

This function is used to set the playback frame based on the slider position.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.