1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Integer) As Integer
Public Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Integer) As Integer
Public Const GWL_STYLE As Integer = (-16)
Public Const WS_VSCROLL As Integer = &H200000
Public Const WS_HSCROLL As Integer = &H100000
..........
Private Sub TreeView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.Click
Dim bVScrollBar As Boolean
Dim x As Integer
x = 0
For i = 1 To 200
bVScrollBar = ((GetWindowLong(Me.TreeView1.Handle, GWL_STYLE) And WS_HSCROLL) = WS_HSCROLL)
If bVScrollBar = True Then
If x < 0 Then Exit Sub
x = x + 1
TreeView1.Width = TreeView1.Width + 10
End If
If bVScrollBar = False Then
If x > 0 Then Exit Sub
x = x - 1
TreeView1.Width = TreeView1.Width - 10
End If
Next
End Sub |
Partager