earthandfire
Programmer
Whilst working on the TGML exercise, I came up against the problem of being able to identify when ScrollBars are visible. I think this has been asked here before, and I'm not sure that there has been answer.
I've tested this with RichTextBox, ListBox and TreeeView and it seems to work:
Call using:
Hope this is of some use.
I've tested this with RichTextBox, ListBox and TreeeView and it seems to work:
Code:
[Blue]Public[/Blue] [Blue]Class[/Blue] HorizontalScroll
[Blue]Public[/Blue] Shared [Blue]Function[/Blue] IsVisible([Blue]ByVal[/Blue] c [Blue]As[/Blue] Control) [Blue]As[/Blue] [Blue]Boolean[/Blue]
[Blue]Dim[/Blue] BorderWidth [Blue]As[/Blue] [Blue]Integer[/Blue] = Math.Abs(Convert.ToInt32(Microsoft.Win32.Registry.CurrentUser.OpenSubKey([Red]"Control Panel"[/Red]).OpenSubKey([Red]"Desktop"[/Red]).OpenSubKey([Red]"WindowMetrics"[/Red]).GetValue([Red]"BorderWidth"[/Red])))
[Blue]Return[/Blue] (c.ClientRectangle.Height + BorderWidth) < c.Height
[Blue]End[/Blue] [Blue]Function[/Blue]
[Blue]End[/Blue] [Blue]Class[/Blue]
[Blue]Public[/Blue] [Blue]Class[/Blue] VerticalScroll
[Blue]Public[/Blue] Shared [Blue]Function[/Blue] IsVisible([Blue]ByVal[/Blue] c [Blue]As[/Blue] Control) [Blue]As[/Blue] [Blue]Boolean[/Blue]
[Blue]Dim[/Blue] BorderWidth [Blue]As[/Blue] [Blue]Integer[/Blue] = Math.Abs(Convert.ToInt32(Microsoft.Win32.Registry.CurrentUser.OpenSubKey([Red]"Control Panel"[/Red]).OpenSubKey([Red]"Desktop"[/Red]).OpenSubKey([Red]"WindowMetrics"[/Red]).GetValue([Red]"BorderWidth"[/Red])))
[Blue]Return[/Blue] (c.ClientRectangle.Width + BorderWidth) < c.Width
[Blue]End[/Blue] [Blue]Function[/Blue]
[Blue]End[/Blue] [Blue]Class[/Blue]
Call using:
Code:
MessageBox.Show(HorizontalScroll.IsVisible(TreeView1).ToString)
MessageBox.Show(VerticalScroll.IsVisible(TreeView1).ToString)
Hope this is of some use.