没有合适的资源?快使用搜索试试~ 我知道了~
自动根据ListBox的最大长度添加横滚动条的软件源码
5星 · 超过95%的资源 需积分: 10 57 下载量 200 浏览量
2011-04-10
08:28:17
上传
评论 1
收藏 1KB TXT 举报
温馨提示
试读
2页
自动根据ListBox的最大长度添加横滚动条喜欢VB的朋友,相信它肯定可以提高编码的效率!
资源推荐
资源详情
资源评论
Option Explicit
'======================================================================
'功能:自动根据ListBox的最大长度添加横滚动条
'用法:Call ListBoxChange(List1)
'======================================================================
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const LB_SETHORIZONTALEXTENT = &H194
Const DT_CALCRECT = &H400
Public Sub ListBoxChange(ByRef lstThis As ListBox)
Dim i As Long
Dim tR As RECT
Dim lW As Long
Dim lWidth As Long
Dim lHDC As Long
With lstThis.Parent.Font
.Name = lstThis.Font.Name
.Size = lstThis.Font.Size
.Bold = lstThis.Font.Bold
.Italic = lstThis.Font.Italic
End With
lHDC = lstThis.Parent.hdc
For i = 0 To lstThis.ListCount - 1
DrawText lHDC, lstThis.List(i), -1, tR, DT_CALCRECT
'======================================================================
'功能:自动根据ListBox的最大长度添加横滚动条
'用法:Call ListBoxChange(List1)
'======================================================================
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const LB_SETHORIZONTALEXTENT = &H194
Const DT_CALCRECT = &H400
Public Sub ListBoxChange(ByRef lstThis As ListBox)
Dim i As Long
Dim tR As RECT
Dim lW As Long
Dim lWidth As Long
Dim lHDC As Long
With lstThis.Parent.Font
.Name = lstThis.Font.Name
.Size = lstThis.Font.Size
.Bold = lstThis.Font.Bold
.Italic = lstThis.Font.Italic
End With
lHDC = lstThis.Parent.hdc
For i = 0 To lstThis.ListCount - 1
DrawText lHDC, lstThis.List(i), -1, tR, DT_CALCRECT
资源评论
- xjhlele2013-11-21很好用哦。
- princess11052014-04-05比较好用哦
- luxingchang19792018-03-20比较实用的参数,继续学习
- imperialeast2014-03-19比较实用的参数
- hustgsd2014-10-13不错不错,实用
tianya166
- 粉丝: 0
- 资源: 46
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功