Is it possible to make the SHBrowseForFolder window modal?
Printable View
Is it possible to make the SHBrowseForFolder window modal?
Yes, the UDT BROWSEINFO has a variable named hWndOwner (Long), it should be the first variable in the UDT. Assign your Form's Hwnd to this variable and the Dialog will be modal to your Form.
HmmQuote:
Originally Posted by jcis
I get error: "Function or interface is marked as restricted, or the function uses an Automation type no supported in Visual Basic"
and it highlights the red part of this line:
frmMain.hWnd = myBI.hWndOwner
Might be because I'm calling this function from a module instead of on the form where it is being used.?
hi, i tried BrowseInfo.hwndOwner = Me.hwnd, it works
Code:
Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const MAX_PATH = 260
Private Declare Function SHBrowseForFolder Lib "shell32" _
(lpBI As BrowseInfo) As Long
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
Private Function BrowseFolder()
Dim lpIDList As Long
Dim sbuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo
szTitle = "Choose PrLr Scheduler Sound Folder"
With tBrowseInfo
.hwndOwner = Me.hwnd
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
sbuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sbuffer
sbuffer = Left(sbuffer, InStr(sbuffer, vbNullChar) - 1)
BrowseFolder = sbuffer
End If
End Function
Ah I see. I had it backwards. ThxQuote:
Originally Posted by xavierjohn22