@@ -30,7 +30,11 @@ public ScrollableControl()
3030 public virtual bool AutoScroll
3131 {
3232 get { return GetScrollState ( ScrollStateAutoScrolling ) ; }
33- set { SetScrollState ( ScrollStateAutoScrolling , value ) ; }
33+ set
34+ {
35+ SetScrollState ( ScrollStateAutoScrolling , value ) ;
36+ PerformLayout ( ) ;
37+ }
3438 }
3539 public override Rectangle DisplayRectangle
3640 {
@@ -113,13 +117,15 @@ internal void Native_EnableScrollBar(bool enable, int orientation)
113117 {
114118 if ( oriV && vscroll != null )
115119 {
120+ vscroll . Value = 0 ; // Reset view.
116121 vscroll . ValueChanged -= Scroll_ValueChanged ;
117122 vscroll . Dispose ( ) ;
118123 vscroll = null ;
119124 }
120125
121126 if ( oriH && hscroll != null )
122127 {
128+ hscroll . Value = 0 ; // Reset view.
123129 hscroll . ValueChanged -= Scroll_ValueChanged ;
124130 hscroll . Dispose ( ) ;
125131 hscroll = null ;
@@ -137,6 +143,22 @@ internal ScrollBar GetScrollBar(int orientation)
137143 return null ;
138144 }
139145
146+ protected internal override void uwfOnLatePaint ( PaintEventArgs e )
147+ {
148+ if ( this is Form )
149+ return ;
150+ if ( vscroll == null || hscroll == null )
151+ return ;
152+
153+ // Fill rect between two scrollbars.
154+ var rx = hscroll . Location . X + hscroll . Width ;
155+ var ry = vscroll . Location . Y + vscroll . Height ;
156+ var rw = Width - rx ;
157+ var rh = Height - ry ;
158+
159+ e . Graphics . uwfFillRectangle ( vscroll . BackColor , rx , ry , rw , rh ) ;
160+ }
161+
140162 protected bool GetScrollState ( int bit )
141163 {
142164 return ( bit & scrollState ) == bit ;
@@ -223,9 +245,8 @@ private void UpdateScrolls()
223245 var autoScroll = ( scrollState & ScrollStateAutoScrolling ) != 0 ;
224246 if ( autoScroll == false )
225247 {
226- HorizontalScroll . UpdateScrollInfo ( ) ;
227- VerticalScroll . UpdateScrollInfo ( ) ;
228- UpdateScrollRects ( ) ;
248+ Native_EnableScrollBar ( false , NativeMethods . SB_VERT ) ;
249+ Native_EnableScrollBar ( false , NativeMethods . SB_HORZ ) ;
229250 return ;
230251 }
231252
@@ -258,7 +279,6 @@ private void UpdateScrolls()
258279
259280 UpdateScrollRects ( ) ;
260281 }
261-
262282 private void UpdateScrollRects ( )
263283 {
264284 var hRightOffset = 0 ;
@@ -279,26 +299,27 @@ private void UpdateScrollRects()
279299 gripOriginLocation . Offset ( - vscroll . Width , 0 ) ;
280300 if ( hscroll != null && vscroll == null )
281301 gripOriginLocation . Offset ( 0 , - hscroll . Height ) ;
282- if ( vscroll != null && hscroll != null )
283- {
284- hRightOffset += 14 ; // img.Width + bottomRight offset
285- vBottomOffset += 14 ;
286- }
287-
302+
288303 form . uwfSizeGripRenderer . Location = gripOriginLocation ;
289304 }
290305 }
291306
307+ if ( vscroll != null && hscroll != null )
308+ {
309+ hRightOffset += 14 ;
310+ vBottomOffset += 14 ;
311+ }
312+
292313 if ( vscroll != null )
293314 {
294- vscroll . Location = new Point ( Width - vscroll . Width , vTopOffset ) ;
295- vscroll . Height = Height - vTopOffset - vBottomOffset ;
315+ vscroll . Location = new Point ( Width - vscroll . Width - 1 , vTopOffset - 1 ) ;
316+ vscroll . Height = Height - vTopOffset - vBottomOffset - 2 ;
296317 }
297318
298319 if ( hscroll != null )
299320 {
300- hscroll . Location = new Point ( 0 , Height - hscroll . Height ) ;
301- hscroll . Width = Width - hRightOffset ;
321+ hscroll . Location = new Point ( 1 , Height - hscroll . Height - 1 ) ;
322+ hscroll . Width = Width - hRightOffset - 2 ;
302323 }
303324 }
304325 }
0 commit comments