Visual C++ and MFC Fundamentals Chapter 18: Progress-Based Controls
CurPos--;
break;case SB_LINEDOWN:
if (CurPos < 255)
CurPos++;
break;case SB_BOTTOM:
CurPos = 255;
break;case SB_ENDSCROLL:
break;case SB_THUMBPOSITION:
CurPos = nPos;
break;case SB_THUMBTRACK:
CurPos = nPos;
break;
}// Set the new position of the thumb (scroll box).
pScrollBar->SetScrollPos(CurPos);// Update each color based on the positions of the scroll bar controls
ColorRed = 255 - m_ScrollRed.GetScrollPos();
ColorGreen = 255 - m_ScrollGreen.GetScrollPos();
ColorBlue = 255 - m_ScrollBlue.GetScrollPos();CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}- Create a timer in the OnInitDialog() event as follows:
SetTimer(1, 40, NULL);return TRUE; // return TRUE unless you set the focus to a control
}- Generate a WM_TIMER message for the dialog box and implement it as follows:
void CPreviewerDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
PaintPreviewArea();CDialog::OnTimer(nIDEvent);
}- Test the application