ListBox横向滚动条
有朋友问到ListBox横向滚动条,百度上有答案,现在把这个单独发个帖子出来,有兴趣的看看程序代码:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function SetWindowPos Lib "user32" _ (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _ ByVal x As Long, ByVal y As Long, ByVal cx As Long, _ ByVal cy As Long, ByVal wFlags As Long) As Long Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long 'api声明 Private Const GWL_STYLE = (-16) Private Const SWP_NOACTIVATE = &H10 Private Const SWP_NOCOPYBITS = &H100 Private Const SWP_NOMOVE = &H2 Private Const SWP_NOOWNERZORDER = &H200 Private Const SWP_NOREDRAW = &H8 Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDER Private Const SWP_NOSIZE = &H1 Private Const SWP_NOZORDER = &H4 Private Const SWP_SHOWWINDOW = &H40 Private Const SWP_FRAMECHANGED = &H20 Private Const WS_HSCROLL = &H100000 Private Const LB_SETHORIZONTALEXTENT = &H194 Private Const LB_GETHORIZONTALEXTENT = &H193 '常量声明 Private Sub Form_Load() Dim Information#, Scrollbar# For Information = 1 To 88 List1.AddItem _ "横滚动条示范横滚动条示范横滚动条示范横滚动条示范横滚动条示范横滚动条示范" & _ "横滚动条示范横滚动条示范横滚动条示范横滚动条示范横滚动条示范横滚动条示范" & _ "横滚动条示范横滚动条示范横滚动条示范横滚动条示范横滚动条示范横滚动条示范" Next Information Information = SendMessageLong(List1.hwnd, LB_SETHORIZONTALEXTENT, 2000, 0) '2000:控制横滚动条的范围(建议值2000-3000) Scrollbar = GetWindowLong(List1.hwnd, GWL_STYLE) Scrollbar = Scrollbar Or WS_HSCROLL SetWindowLong List1.hwnd, GWL_STYLE, Scrollbar SetWindowPos List1.hwnd, _ 0, 0, 0, 0, 0, _ SWP_NOMOVE Or SWP_NOOWNERZORDER Or SWP_NOSIZE Or SWP_FRAMECHANGED End Sub
[[it] 本帖最后由 三断笛 于 2008-5-29 02:38 编辑 [/it]]