I am using a 3rd party grid control that displays a
vertical scrollbar when the grid fills up. I need to know
if the vertical scrollbar is visible or not. I have been
told that I can use the API to do this, but I don't know
how. Anyone have an idea? Thanks!
Christopher Hughes
You can check the state of the WS_VSCROLL (or WS_HSCROLL) window style
bit with the Api.
Ex:
'api declarations - bas module...
Public Const GWL_STYLE = (-16)
Public Const WS_VSCROLL = &H200000
Public Const WS_HSCROLL = &H100000
Public Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
'usage - anywhere...
Dim Style As Long
Style = GetWindowLong(Grid1.hwnd, GWL_STYLE)
If (Style And WS_VSCROLL) Then
'...vert scrollbar is visible...
End If
-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
Is there also a way I could disable the scrollbar
completely using API ?
Chris
You can use EnableScrollBar or perhaps ShowScrollBar, whichever works
best. Not sure how the Grid control behaves in this regard, but the
control may re-set the state when the contents change or the window is
redrawn. (i.e. you may not be able to just set it once and expect it
to stay that way.)
'declares...
' Scroll Bar Constants
Public Const SB_HORZ = 0&
Public Const SB_VERT = 1&
Public Const SB_CTL = 2&
Public Const SB_BOTH = 3&
' EnableScrollBar() flags
Public Const ESB_ENABLE_BOTH = &H0
Public Const ESB_DISABLE_BOTH = &H3
Public Const ESB_DISABLE_LEFT = &H1
Public Const ESB_DISABLE_RIGHT = &H2
Public Const ESB_DISABLE_UP = &H1
Public Const ESB_DISABLE_DOWN = &H2
Public Declare Function EnableScrollBar Lib "user32" _
(ByVal hwnd As Long, ByVal wSBflags As Long, _
ByVal wArrows As Long) As Long
Public Declare Function ShowScrollBar Lib "user32" _
(ByVal hwnd As Long, ByVal wBar As Long, _
ByVal bShow As Long) As Long
'usage...
'disable vert scrollbar...
EnableScrollBar Grid1.hwnd, SB_VERT, ESB_DISABLE_BOTH
'...or hide it...
ShowScrollBar Grid1.hwnd, SB_VERT, 0