⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 144.txt

📁 介绍VB里的各种控件的使用方法,窗口控制,图像编程以及OCX等内容,还提供了一个API集供参考.
💻 TXT
字号:
往列表框中填入文件目录信息   


 This routine demonstrated using the API and a standard listbox to duplicate the functionality of a FileList Box. By using this method over the FileListBox, you can control the files, directories and drives displayed. 

 Note however that the constant value for 'READWRITE' is 0, the same as the vb constant 'Archive'. In VB you can not mask out the archive files to only return hidden files (for example). But by using the API value DDL_EXCLUSIVE Or'd with the type to be listed, you have control over the display of files. 

 The added bonus is that this method is instantaneous.

 Add the following code to a BAS module: 
---------------------------------------------------------------

Public Declare Function SendMessageStr Lib _
 "user32" Alias "SendMessageA" _
 (ByVal hwnd As Long, _
  ByVal wMsg As Long, _
  ByVal wParam As Long, _
  ByVal lParam As String) As Long

Public 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

Public Const LB_DIR = &H18D
Public Const LB_RESETCONTENT = &H184

Public Const DDL_READWRITE = &H0
Public Const DDL_READONLY = &H1
Public Const DDL_HIDDEN = &H2
Public Const DDL_SYSTEM = &H4
Public Const DDL_DIRECTORY = &H10
Public Const DDL_ARCHIVE = &H20
Public Const DDL_DRIVES = &H4000
Public Const DDL_EXCLUSIVE = &H8000
Public Const DDL_POSTMSGS = &H2000
Public Const DDL_FLAGS = DDL_ARCHIVE Or DDL_DIRECTORY
'--end block--

-------------------------------------------------------------------
 Create a form containing six command buttons in a control array (Command1(0) - Command1(5)), and a listbox. Add the following code to the form: 

-------------------------------------------------------------------

Private Sub Command1_Click(Index As Integer)

  Dim r As Long
  Dim DDL_FLAGS As Long
  Dim searchPath As String

  searchPath = "c:\win\*.*"

  Select Case Index
   Case 0: DDL_FLAGS = DDL_EXCLUSIVE Or DDL_ARCHIVE
   Case 1: DDL_FLAGS = DDL_EXCLUSIVE Or DDL_ARCHIVE Or DDL_DIRECTORY
   Case 2: DDL_FLAGS = DDL_EXCLUSIVE Or DDL_HIDDEN
   Case 3: DDL_FLAGS = DDL_EXCLUSIVE Or DDL_SYSTEM
   Case 4: DDL_FLAGS = DDL_EXCLUSIVE Or DDL_DIRECTORY
   Case 5: DDL_FLAGS = DDL_EXCLUSIVE Or DDL_DRIVES
   Case Else
  End Select

 'clear and populate the listbox
  Call SendMessageLong(List1.hwnd, LB_RESETCONTENT, 0, 0)
  Call SendMessageStr(List1.hwnd, LB_DIR, DDL_FLAGS, ByVal searchPath)

  Label1 = r + 1 & " " & Command1(Index).Caption & " found."

End Sub
'--end block--
-------------------------------------------------------------------

 By changing the value of the DDL_FLAGS parameter to include or exclude specific DDL_ constants, you determine the type of file structure to include into the list.

 For an explanation of my usage of SendMessageLong and SendMessageStr, see Using the Windows SendMessage API Successfully in the Resource Centre.  

⌨️ 快捷键说明

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