| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2533 人关注过本帖
标题:ListBox横向滚动条
只看楼主 加入收藏
三断笛
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:31
帖 子:1621
专家分:1617
注 册:2007-5-24
结帖率:37.5%
收藏
 问题点数:0 回复次数:3 
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]]
搜索更多相关主题的帖子: ListBox 滚动 
2008-05-29 02:35
flyue
Rank: 10Rank: 10Rank: 10
来 自:江南西道
等 级:贵宾
威 望:19
帖 子:3465
专家分:1563
注 册:2006-6-20
收藏
得分:0 
想不到用VB实现横向滚动条这么麻烦啊……
在VC里你只要直接钩选“横向滚动条”即可

天之道,损有余而补不足.人之道则不然,损不足以奉有余.孰能有余以奉天下,唯有道者.
2008-05-30 13:38
jrs123
Rank: 2
等 级:论坛游民
威 望:1
帖 子:627
专家分:14
注 册:2006-9-5
收藏
得分:0 
这也是VB被微软PK的原因之一吧
2008-05-30 13:42
flyue
Rank: 10Rank: 10Rank: 10
来 自:江南西道
等 级:贵宾
威 望:19
帖 子:3465
专家分:1563
注 册:2006-6-20
收藏
得分:0 
咳…咳咳……

天之道,损有余而补不足.人之道则不然,损不足以奉有余.孰能有余以奉天下,唯有道者.
2008-05-30 17:55
快速回复:ListBox横向滚动条
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030474 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved