1

I need to move controls around when the scrollbar's size change (System.Windows.Forms.SystemInformation.VerticalScrollBarWidth).

I'm creating a control with custom scrollbars that go over the normal ones. This implies creating a new UserControl (not inheriting a built-in control) and playing around with panels so as to hide the normal scrollbars.

The custom control must have one "outer" panel at the right size, this one containing an "inner" panel larger than the outer panel, so the scrollbars do not appear. How much larger depends on System.Windows.Forms.SystemInformation.VerticalScrollBarWidth and HorizontalScrollBarHeight as was already answered. But then I must know if that changes when my app is running, as improbable as it seems.

This question is related to: How do I know the current width of system scrollbar?

Community
  • 1
  • 1
Gabriel
  • 2,841
  • 4
  • 33
  • 43

2 Answers2

1

I'm currently trying to achieve something similar.

I'm running Windows XP SP3, "Classic" style, and upon changing just the scrollbar width of the current design, my override of OnSystemColorsChanged() (in a class derived from Control) gets called four times.

Why it's four times I don't really know, I suspected it might be because there's four properties in there that seem to depend on that setting:

SystemInformation.HorizontalScrollBarArrowWidth
SystemInformation.HorizontalScrollBarHeight
SystemInformation.VerticalScrollBarArrowHeight
SystemInformation.VerticalScrollBarWidth

But all of these already hold the new value at time of the first call. So I'm not 100% sure what's going on here. But it looks like OnSystemColourChanged() should rather be called OnSystemInformationChanged(). Hope this helps ...

takrl
  • 6,356
  • 3
  • 60
  • 69
1

One must listen to Microsoft.Win32.SystemEvents.UserPreferenceChanged. As takrl mentioned, OnSystemColorsChanged gets called, but only once for me (Windows7, Framework 3.5)

Gabriel
  • 2,841
  • 4
  • 33
  • 43