Private Declare Function GetScrollRange Lib "user32" (ByVal hwnd As Long, ByVal nBar As Long, lpMinPos As Long, lpMaxPos As Long) As Long
Private Declare Function SetScrollRange Lib "user32" (ByVal hwnd As Long, ByVal nBar As Long, ByVal nMinPos As Long, ByVal nMaxPos As Long, ByVal bRedraw As Long) As Long
Private Sub Form_Activate()
' MSHFlexGrid1.Width = Me.Width
Call SetScrollRange(MSHFlexGrid1.hwnd, SB_HORZ, 0, Me.Width, True)
End Sub
Private Sub Command1_Click()
MsgBox HeScroll(MSHFlexGrid1) '判断水平滚动条是否存在
MsgBox VsScroll(MSHFlexGrid1) '判断垂直滚动条是否存在
End Sub
Public Function VsScroll(MshGrid As MSHFlexGrid) As Boolean '判断水平滚动条的可见性
Dim i As Long
VsScroll = False
i = GetScrollRange(MshGrid.hwnd, SB_HORZ, lpMinPos, lpMaxPos)
If lpMaxPos <> lpMinPos Then VsScroll = True
End Function
Public Function HeScroll(MshGrid As MSHFlexGrid) As Boolean '判断垂直滚动条的可见性
Dim i As Long
HeScroll = False
i = GetScrollRange(MshGrid.hwnd, SB_VERT, lpMinPos, lpMaxPos)
If lpMaxPos <> lpMinPos Then HeScroll = True
End Function