MCPcopy Create free account
hub / github.com/audiorouterdev/audio-router / OnHScroll

Method OnHScroll

audio-router-gui/ScrollHelper.cpp:115–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115void CScrollHelper::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
116{
117 if ( m_attachWnd == NULL )
118 return;
119
120 const int lineOffset = 60;
121
122 // Compute the desired change or delta in scroll position.
123 int deltaPos = 0;
124 switch( nSBCode )
125 {
126 case SB_LINELEFT:
127 // Left scroll arrow was pressed.
128 deltaPos = -lineOffset;
129 break;
130
131 case SB_LINERIGHT:
132 // Right scroll arrow was pressed.
133 deltaPos = lineOffset;
134 break;
135
136 case SB_PAGELEFT:
137 // User clicked inbetween left arrow and thumb.
138 deltaPos = -m_pageSize.cx;
139 break;
140
141 case SB_PAGERIGHT:
142 // User clicked inbetween thumb and right arrow.
143 deltaPos = m_pageSize.cx;
144 break;
145
146 case SB_THUMBTRACK:
147 // Scrollbar thumb is being dragged.
148 deltaPos = Get32BitScrollPos(SB_HORZ, pScrollBar) - m_scrollPos.cx;
149 break;
150
151 case SB_THUMBPOSITION:
152 // Scrollbar thumb was released.
153 deltaPos = Get32BitScrollPos(SB_HORZ, pScrollBar) - m_scrollPos.cx;
154 break;
155
156 default:
157 // We don't process other scrollbar messages.
158 return;
159 }
160
161 // Compute the new scroll position.
162 int newScrollPos = m_scrollPos.cx + deltaPos;
163
164 // If the new scroll position is negative, we adjust
165 // deltaPos in order to scroll the window back to origin.
166 if ( newScrollPos < 0 )
167 deltaPos = -m_scrollPos.cx;
168
169 // If the new scroll position is greater than the max scroll position,
170 // we adjust deltaPos in order to scroll the window precisely to the
171 // maximum position.
172 int maxScrollPos = m_displaySize.cx - m_pageSize.cx;

Callers

nothing calls this directly

Calls 1

SetScrollPosMethod · 0.45

Tested by

no test coverage detected