class CPractice9_1Dlg : public CDialog
{
// {
void HandleSeekbar(UINT nSBCode);
...
// }
// Construction
public:
CAudioboxDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CPractice9_1Dlg)
enum { IDD = IDD_PRACTICE9_1_DIALOG };
CSliderCtrl m_sliderBlue;
...
//}}AFX_DATA
...
// Generated message map functions
//{{AFX_MSG(CPractice9_1Dlg)
...
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnReleasedcaptureSliderRed(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
void CPractice9_1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPractice9_1Dlg)
DDX_Control(pDX, IDC_SLIDER_BLUE, m_sliderBlue);
...
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPractice9_1Dlg, CDialog)
//{{AFX_MSG_MAP(CPractice9_1Dlg)
...
ON_WM_HSCROLL()
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_RED, OnReleasedcaptureSliderRed)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
...
BOOL CPractice9_1Dlg::OnInitDialog()
{
...
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
// {
m_sliderBlue.SetRange(0, 255);
...
// }
return TRUE; // return TRUE unless you set the focus to a control
}
...
void CPractice9_1Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
// {
HandleSeekbar(nSBCode);
// }
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CPractice9_1Dlg::HandleSeekbar(UINT nSBCode)
{
HRESULT hr;
static BOOL bStartOfScroll = TRUE;
...
DWORD dwPosition = m_sliderBlue.GetPos();
// When the scroll action begins. // save current state
if (bStartOfScroll)
{
...
bStartOfScroll = FALSE;
}
// Update the position continuously.
...
// Restore the state at the end.
if (nSBCode == TB_ENDTRACK)
{
...
bStartOfScroll = TRUE;
}
...
}
void CPractice9_1Dlg::OnReleasedcaptureSliderRed(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
// {
int nRed = m_sliderBlue.GetPos();
...
// }
*pResult = 0;
}