+ int max = (int)(m_hAdjust->upper - m_hAdjust->page_size + 0.5);
+ if (max < 0) max = 0;
+
+ int x_pos = m_xScrollPosition;
+ if (x_pos > max) x_pos = max;
+ if (x_pos < 0) x_pos = 0;
+
+ int old_x = m_xScrollPosition;
+ m_xScrollPosition = x_pos;
+ m_hAdjust->value = x_pos;
+
+ if (x_pos != old_x)
+ m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 );
+ }
+