Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21238

detecting a vscrollbar in msflexgrid vb6

$
0
0
I am trying to set the width of a Msflexgrid based on if it has a vertical scrollbar

Code:

Code:

Const GWL_STYLE = (-16)
Const WS_VSCROLL = &H200000
Const WS_HSCROLL = &H100000
 
Private Declare Function GetWindowLong Lib "user32" _
    Alias "GetWindowLongA" ( _
        ByVal Hwnd As Long, _
        ByVal nIndex As Long) As Long
 
'==================================================================
Public Function IsHScrollVisible(Hwnd As Long) As Boolean
    Dim Style As Long
    Style = GetWindowLong(Hwnd, GWL_STYLE)
 
    If (Style And WS_HSCROLL) Then
        IsHScrollVisible = True
        Exit Function
    End If
 
End Function
 
'==================================================================
Public Function IsVScrollVisible(Hwnd As Long) As Boolean
    Dim Style As Long
    Style = GetWindowLong(Hwnd, GWL_STYLE)
 
    If (Style And WS_VSCROLL) Then
        IsVScrollVisible = True
        Exit Function
    End I
 
End Function
 



Sub PositionForm_Grid
gridStats.Width = 12184
     
  If IsVScrollVisible(gridStats.Hwnd) = False Then
    gridStats.Width = 11800
  End If

The first time this Function is called it is false(this is correct)
The second time it reports true even though its not visible
Why is this ?

Viewing all articles
Browse latest Browse all 21238

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>