?? 用api根據(jù)listbox最長項目的寬度來設(shè)置滾動條.frm
字號:
VERSION 5.00
Begin VB.Form Form1
Caption = "設(shè)定適當寬度的水平滾動條"
ClientHeight = 2670
ClientLeft = 60
ClientTop = 345
ClientWidth = 3630
BeginProperty Font
Name = "MS Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 2670
ScaleWidth = 3630
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "設(shè)定適當寬度的水平滾動條"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 1
Top = 2040
Width = 3375
End
Begin VB.ListBox List1
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1680
ItemData = "用API根據(jù)ListBox最長項目的寬度來設(shè)置滾動條.frx":0000
Left = 120
List = "用API根據(jù)ListBox最長項目的寬度來設(shè)置滾動條.frx":0187
TabIndex = 0
Top = 120
Width = 3375
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim max As Long, f As Font, i As Integer
Me.ScaleMode = vbPixels
Set f = Me.Font
Set Me.Font = List1.Font
With List1
For i = 0 To .ListCount
If Me.TextWidth(.List(i)) > max Then
max = Me.TextWidth(.List(i))
End If
Next
End With
max = max + 10
Set Me.Font = f
SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, max, ByVal 0&
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -