关于对话框

mili111 2003-08-27 08:32:13
怎样弹出在windows安装驱动程序时指明文件路径时出现的树型目录???????
...全文
78 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
iiboy 2003-08-27
  • 打赏
  • 举报
回复
问题较高深!
学习.
道素 2003-08-27
  • 打赏
  • 举报
回复
.ulFlags = BIF_BROWSEINCLUDEFILES
这个属性设定风格,比如
Const BIF_BROWSEFORCOMPUTER = &H1000 选择目标是计算机
Const BIF_BROWSEFORPRINTER = &H2000 目标打印机
Const BIF_BROWSEINCLUDEFILES = &H4000

Const BIF_USENEWUI = (BIF_NEWDIALOGSTYLE Or BIF_EDITBOX)
新的样式(有新建文件夹按钮)及一个文本框
道素 2003-08-27
  • 打赏
  • 举报
回复
Option Explicit

Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Const BIF_RETURNONLYFSDIRS = 1
Const BIF_NEWDIALOGSTYLE = &H40
Const BIF_EDITBOX = &H10
Const MAX_PATH = 260

Const BIF_BROWSEFORCOMPUTER = &H1000
Const BIF_BROWSEFORPRINTER = &H2000
Const BIF_BROWSEINCLUDEFILES = &H4000
Const BIF_DONTGOBELOWDOMAIN = &H2
Const BIF_RETURNFSANCESTORS = &H8
Const BIF_STATUSTEXT = &H4
Const BIF_USENEWUI = (BIF_NEWDIALOGSTYLE Or BIF_EDITBOX)

Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Load()
Dim iNull As Integer, lpIDList As Long, lResult As Long
Dim sPath As String, udtBI As BrowseInfo

With udtBI
'Set the owner window
.hWndOwner = Me.hWnd
'lstrcat appends the two strings and returns the memory address
.lpszTitle = lstrcat("C:\", "")
'Return only if the user selected a directory
.ulFlags = BIF_BROWSEINCLUDEFILES
End With

'Show the 'Browse for folder' dialog
lpIDList = SHBrowseForFolder(udtBI)
If lpIDList Then
sPath = String$(MAX_PATH, 0)
'Get the path from the IDList
SHGetPathFromIDList lpIDList, sPath
'free the block of memory
CoTaskMemFree lpIDList
iNull = InStr(sPath, vbNullChar)
If iNull Then
sPath = Left$(sPath, iNull - 1)
End If
End If

MsgBox sPath
End Sub

zymfy 2003-08-27
  • 打赏
  • 举报
回复
用Dir1listbox控件呀

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧