Results 1 to 5 of 5

Thread: Make SHBrowseForFolder Modal?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    211

    Make SHBrowseForFolder Modal?

    Is it possible to make the SHBrowseForFolder window modal?

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Make SHBrowseForFolder 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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    211

    Re: Make SHBrowseForFolder Modal?

    Quote Originally Posted by jcis
    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.
    Hmm

    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.?

  4. #4
    Addicted Member xavierjohn22's Avatar
    Join Date
    Oct 2006
    Location
    Approx. 4921' and 3.11" asl
    Posts
    249

    Re: Make SHBrowseForFolder Modal?

    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

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    211

    Re: Make SHBrowseForFolder Modal?

    Quote Originally Posted by xavierjohn22
    hi, i tried BrowseInfo.hwndOwner = Me.hwnd, it works
    Ah I see. I had it backwards. Thx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width