📄 comboboxex1.frm
字号:
VERSION 5.00
Begin VB.Form Demo1
BorderStyle = 3 'Fixed Dialog
Caption = "Demo1"
ClientHeight = 2460
ClientLeft = 5790
ClientTop = 3840
ClientWidth = 3945
LinkTopic = "Form3"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 123
ScaleMode = 2 'Point
ScaleWidth = 197.25
StartUpPosition = 2 'CenterScreen
Tag = "1"
Begin VB.CommandButton Command3
Caption = "Command3"
Height = 480
Left = 9555
TabIndex = 4
Top = 1605
Width = 405
End
Begin VB.PictureBox Picture3
Height = 315
Left = 3555
ScaleHeight = 255
ScaleWidth = 255
TabIndex = 1
Top = 585
Width = 315
End
Begin VB.PictureBox Picture1
Height = 315
Left = 3240
ScaleHeight = 255
ScaleWidth = 240
TabIndex = 0
Top = 585
Width = 300
End
Begin VB.Image Image1
Height = 480
Left = 3015
Picture = "ComboBoxEx1.frx":0000
Top = 1230
Visible = 0 'False
Width = 480
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Label1"
Height = 195
Left = 225
TabIndex = 3
Top = 1245
Width = 480
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Label1"
Height = 195
Left = 225
TabIndex = 2
Top = 270
Width = 480
End
End
Attribute VB_Name = "Demo1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private ComboExL As New ComboBoxEx
Private ComboExS As New ComboBoxEx
Private Const CBN_SELCHANGE = 1
Private Const WM_COMMAND = &H111
Private Sub Form_Load()
Picture1.BorderStyle = 0
Picture3.BorderStyle = 0
With ComboExS
Set .Parent = Me
.Create 10, 39, 200, 170, , 16, True
.Additems "Explorer", 0, 0, 0, ComboExL.GetWinDir & "\Explorer.exe", 1
.Additems "NotePad", 1, 1, 0, ComboExL.GetWinDir & "\Notepad.exe"
.Additems "WinHelp", 2, 2, 0, ComboExL.GetWinDir & "\WinHelp.exe"
.Additems "Welcome", 3, 3, 0, ComboExL.GetWinDir & "\Welcome.exe"
End With
With ComboExL
Set .Parent = Me
.FontName = "Arial"
.FontHeight = 18
.FontBold = True
.FontItalic = True
.FontUnderlined = True
.Create 10, 102, 200, 270, , 32
.AddIcon Image1.Picture
.Additems "Microsoft Home", 0, 0, 0, "http://www.microsoft.com"
.Additems "Visual Basic Home", 1, 0, 0, "http://www.microsoft.com/vbasic"
.Additems "Owners' Area", 2, 0, 0, "http://www.microsoft.com/vstudio/owner/default.asp"
.Additems "ZoneCorp", 3, 0, 0, "http://www.ZoneCorp.com"
End With
SubClass Me.hWnd
ComboExS.SetIndex 0
Label1 = ComboExS.GetText & " (" & ComboExS.GetPath & ")"
ComboExS.GetComboIcon Picture1, cbNormal
ComboExS.GetComboIcon Picture3, cbDisabled
ComboExL.SetIndex 0
Label2 = ComboExL.GetText & " (" & ComboExL.GetPath & ")"
DoEvents
End Sub
Public Sub ProcMsg(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long, Result As Long)
On Error Resume Next
Select Case uMsg
Case WM_COMMAND
If (wParam \ &H10000 And &HFFFF&) = CBN_SELCHANGE Then
Select Case lParam
Case ComboExS.GetComboHwnd
Label1 = ComboExS.GetText & " (" & ComboExS.GetPath & ")"
ComboExS.GetComboIcon Picture1, cbNormal
ComboExS.GetComboIcon Picture3, cbDisabled
Case ComboExL.GetComboHwnd
Label2 = ComboExL.GetText
ComboExL.RunFile ComboExL.GetPath
End Select
End If
End Select
End Sub
Private Sub SubClass(hWnd As Long)
On Error Resume Next
NextProcs1 = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProcDemo1)
End Sub
Private Sub UnSubClass()
Dim hWndCur As Long
hWndCur = Me.hWnd
If NextProcs1 Then
SetWindowLong hWndCur, GWL_WNDPROC, NextProcs1
NextProcs1 = 0
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnSubClass
ComboExS.Destroy
ComboExL.Destroy
Set ComboExS = Nothing
Set ComboExL = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -