1 //////////////////////////////////////////////
\r
5 #include "ScrollBar.h"
\r
6 #include "DialogApp.h"
\r
9 CMyScrollBar::CMyScrollBar()
\r
11 ZeroMemory(&m_si, sizeof(SCROLLINFO));
\r
14 void CMyScrollBar::OnInitialUpdate()
\r
16 // Called automatically via AttachDlgItem
\r
18 // Set the Scroll bar position
\r
22 LRESULT CMyScrollBar::OnMessageReflect(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
24 UNREFERENCED_PARAMETER(lParam);
\r
30 // Get a reference to the MyDialog object
\r
31 CMyDialog& MyDialog = GetDialogApp().GetDialog();
\r
33 GetScrollInfo(&m_si);
\r
35 switch (LOWORD (wParam))
\r
37 // user clicked left arrow
\r
42 // user clicked right arrow
\r
47 // user clicked the scroll bar shaft left of the scroll box
\r
49 m_si.nPos -= m_si.nPage;
\r
52 // user clicked the scroll bar shaft right of the scroll box
\r
54 m_si.nPos += m_si.nPage;
\r
57 // user dragged the scroll box
\r
59 m_si.nPos = m_si.nTrackPos;
\r
66 MyDialog.SetScroll(m_si.nPos); // Set the scroll bar position
\r
67 MyDialog.SetSlider(m_si.nPos); // Set the slider position
\r
68 MyDialog.SetProgress(m_si.nPos); // Set the progress bar position
\r
69 MyDialog.SetStatic(FALSE, m_si.nPos); // Set the static text
\r
78 void CMyScrollBar::SetScroll(int nPos)
\r
80 m_si.cbSize = sizeof(SCROLLINFO);
\r
83 m_si.nMax = 100 + (m_si.nPage -1);
\r
84 m_si.fMask = SIF_ALL;
\r
86 // Set the scroll bar position
\r
87 SetScrollInfo(&m_si, TRUE);
\r