📄 browsdlg.frm
字号:
Height = 315
Index = 13
Left = 180
TabIndex = 13
Top = 4200
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "Desktop Folder"
Height = 315
Index = 12
Left = 180
TabIndex = 12
Top = 3900
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "Start Menu Folder"
Height = 315
Index = 11
Left = 180
TabIndex = 11
Top = 3600
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "Recycle Bin(*)"
Height = 315
Index = 10
Left = 180
TabIndex = 10
Top = 3300
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "Printers*"
Height = 315
Index = 4
Left = 180
TabIndex = 4
Top = 1500
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "SendTo Folder"
Height = 315
Index = 9
Left = 180
TabIndex = 9
Top = 3000
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "Recent Folder"
Height = 315
Index = 8
Left = 180
TabIndex = 8
Top = 2700
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "Startup Folder"
Height = 315
Index = 7
Left = 180
TabIndex = 7
Top = 2400
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "Favorites Folder"
Height = 315
Index = 6
Left = 180
TabIndex = 6
Top = 2100
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "Documents Folder"
Height = 315
Index = 5
Left = 180
TabIndex = 5
Top = 1800
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "Programs Folder"
Height = 315
Index = 2
Left = 180
TabIndex = 2
Top = 900
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "Control Panel*"
Height = 315
Index = 3
Left = 180
TabIndex = 3
Top = 1200
Width = 1800
End
Begin VB.OptionButton Option1
Caption = "The Desktop*"
Height = 315
Index = 1
Left = 180
TabIndex = 1
Top = 600
Width = 1800
End
End
Begin VB.CommandButton Command1
Caption = "&Browse..."
Height = 345
Left = 3480
TabIndex = 19
Top = 6120
Width = 1275
End
Begin VB.Label Label1
Caption = "* virtual folder"
Height = 195
Left = 600
TabIndex = 40
Top = 5940
Width = 1695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim nFolder& ' system folder to begin browse in
Dim CurOptIdx% ' currently selected option button
Private Sub Form_Load()
Dim idx&, item&
Dim rtn&, path$
Dim idl As ITEMIDLIST
For idx& = 1 To 17
' see BrowsDlg.bas for the system folder flag values
' The Desktop
If idx& = 1 Then
item& = 0
' Programs Folder -> Start Menu Folder
ElseIf idx& > 1 And idx& < 12 Then
item& = idx&
' Desktop Folder -> ShellNew Folder
ElseIf idx& >= 12 Then
item& = idx& + 4&
End If
' fill the idl structure with the specified folder item
rtn& = SHGetSpecialFolderLocation(Me.hWnd, item&, idl)
If rtn& = NOERROR Then
' if the structure is filled, initialize the var & get the path from the id list
path$ = Space$(512)
rtn& = SHGetPathFromIDList(ByVal idl.mkid.cb, ByVal path$)
' if a path was found in the structure, display it in the respective text box
If rtn& Then Text1(idx&) = path$
End If
Next
End Sub
Private Sub Option1_Click(Index As Integer)
' see the "bi.lpszTitle=..." line in Command1_Click
' save the current option btn for dialog banner display
CurOptIdx% = Index
' save the value of the system folder to begin dialog display from
If Index = 1 Then
nFolder& = 0
ElseIf Index < 12 Then
nFolder& = Index
Else
nFolder& = Index + 4
End If
End Sub
Private Sub Command1_Click()
Dim bi As BROWSEINFO
Dim idl As ITEMIDLIST
Dim rtn&, pidl&, path$, pos%
' the calling app
bi.hOwner = Me.hWnd
' set the folder to limit the browse to in the dialog
' if CurOptIdx% = 0 (Default Browse), bi.pidlRoot would then be Null
If CurOptIdx% Then
rtn& = SHGetSpecialFolderLocation(ByVal Me.hWnd, ByVal nFolder&, idl)
bi.pidlRoot = idl.mkid.cb
End If
' set the banner text
bi.lpszTitle = "Browsing is limited to: " & Option1(CurOptIdx%).Caption
' set the type of folder to return
' play with these option constants to see what can be returned
bi.ulFlags = BIF_RETURNONLYFSDIRS 'BIF_RETURNFSANCESTORS 'BIF_BROWSEFORPRINTER + BIF_DONTGOBELOWDOMAIN
' show the browse folder dialog
pidl& = SHBrowseForFolder(bi)
' if displaying the return value, get the selected folder
If Check1 Then
path$ = Space$(512)
rtn& = SHGetPathFromIDList(ByVal pidl&, ByVal path$)
If rtn& Then
' parce & display the folder selection
pos% = InStr(path$, Chr$(0))
MsgBox "Folder selection was:" & Chr$(10) & Chr$(10) & Left(path$, pos - 1), vbInformation
Else
MsgBox "Dialog was cancelled", vbInformation
End If
End If
End Sub
Private Sub Command2_Click()
Dim msg$, lf$
lf$ = Chr$(10)
msg$ = "If an item has no folder location displayed, then it has no Registry entry under:" & lf$ & lf$
msg$ = msg$ & "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" & lf$ ' & lf$
'msg$ = msg$ & "If one of these items is selected from the Browse dialog, it will return 0 (cancelled) to the calling proc."
MsgBox msg$
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set Form1 = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -