comboboxex.frm

来自「收集的100多个适合不同层次VB爱好者编程的实例源码」· FRM 代码 · 共 78 行

FRM
78
字号
VERSION 5.00
Begin VB.Form Demo 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "带图形的ComboBox"
   ClientHeight    =   2775
   ClientLeft      =   5025
   ClientTop       =   3405
   ClientWidth     =   4815
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2775
   ScaleWidth      =   4815
   StartUpPosition =   2  '屏幕中心
   Begin VB.TextBox Text1 
      Height          =   330
      Left            =   120
      MaxLength       =   256
      TabIndex        =   0
      Top             =   2400
      Width           =   4440
   End
End
Attribute VB_Name = "Demo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 
Private ComboEx As New ComboBoxEx
Private Const CBN_SELCHANGE = 1
Private Const WM_COMMAND = &H111

Private Sub Form_Load()
 
With ComboEx
Set .Parent = Me
.Create 70, 20, 200, 170, , 16
End With
 

'This routine is in the ComboBoxEx Class
'ComboEx.GetAllDrives
 

Dim LastItem As Integer
Dim Drv As String, lResult As Long, DrvLetter As String

'ComboEx.Additems
'StringToAdd as string = DisplayText
'Index as integer = zero Based index in ComboBox
'ImgIndex as integer = Zero Based index of picture in ImageList
'InDent As Integer = Indentation
'[FileName As String] = Optional FileName to extract icon from
'If Blank and IconInFile is blank or -1 then it will get the Icon From System Imagelist
'[IconInFile As Integer = -1] = Gets the icon from the file
'If FileName is blank and IconInFile <> -1 then it will extract the Icon From Shell32.dll

ComboEx.Additems "Desktop", 0, 0, 0, , 34
ComboEx.Additems "My Computer", 1, 1, 1, ComboEx.GetWinDir & "\Explorer.exe", 0

LastItem = 2

Drv = String$(128, 0)

lResult = GetLogicalDriveStrings(1024, Drv)

   Do While Left$(Drv, 1) <> Chr$(0)

        DrvLetter = UCase$(Left$(Drv, 3))
        Drv = Mid$(Drv, 5)

        DrvType = GetDriveType(DrvLetter)

        Select Case DrvType
            Case DRIVE_REMOVABLE
                 If DrvLetter = "A:\" Then
                 ComboEx.Additems "3 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?