下面的代码可以看看目标窗口是否具有WS_VSCROLL或WS_HSCROLL风格Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Const GWL_STYLE = (-16) Private Const WS_VSCROLL = &H200000 Private Const WS_HSCROLL = &H100000Private Sub Form_Load() Dim lStyle As Long lStyle = GetWindowLong(Text1.hwnd, GWL_STYLE) If lStyle And WS_HSCROLL Or lStyle And WS_VSCROLL Then Debug.Print "yes" Else Debug.Print "no" End If End Sub如果为no的话,那不管怎么弄都不会出现滚动条的……
具有ws_vscroll ws_hscroll风格的,不属于窗体,无句柄
有些滚动条是单独的滚动条控件,一般都有句柄
也有单独的滚动条控件无句柄的,那是windowless控件
Private Const GWL_STYLE = (-16)
Private Const WS_VSCROLL = &H200000
Private Const WS_HSCROLL = &H100000Private Sub Form_Load()
Dim lStyle As Long
lStyle = GetWindowLong(Text1.hwnd, GWL_STYLE)
If lStyle And WS_HSCROLL Or lStyle And WS_VSCROLL Then
Debug.Print "yes"
Else
Debug.Print "no"
End If
End Sub如果为no的话,那不管怎么弄都不会出现滚动条的……