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.