Announcement

Collapse
No announcement yet.

BrowseForFolder/File

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • BrowseForFolder/File

    This is just more curiosity than anything.
    The function below does a nice job of browsefor folder, great, but in Win2k I'm seeing where the OS uses this to brose for a file.

    Is there a flag that is missing here that allows it to do that?


    Code:
    '--<For the Browse for folder routines----------------------------------------------
    %bif_returnonlyfsdirs       = &h0001
    %bif_dontgobelowdomain      = &h0002
    %bif_statustext             = &h0004
    %bif_returnfsancestors      = &h0008
    %bif_browseforcomputer      = &h1000
    %bif_browseforprinter       = &h2000
    
    %bffm_initialized           = 1
    %bffm_selchanged            = 2
    %bffm_setstatustext         = %WM_USER + 100
    %bffm_enableok              = %WM_USER + 101
    %bffm_setselection          = %WM_USER + 102     
    '
    '
    '
    
    Function BrowseForFolder(hWnd As Long, Title As String,StartDir As String) Export As String
    Local zbuffer As Asciiz * %max_path
    Local zstartdir As Asciiz * %max_path
    Local bi As browseinfo
    zstartdir = StartDir
    bi.hwndowner = hWnd
    bi.lpsztitle = StrPtr(Title)
    bi.ulflags = %bif_returnonlyfsdirs Or %bif_dontgobelowdomain Or %bif_statustext
    bi.pidlroot = 0
    bi.lpfncallback = CodePtr(fbrowseproc)
    bi.lparam = VarPtr(zstartdir)
    lpidlist& = shbrowseforfolder(bi)
    If lpidlist& Then
        shgetpathfromidlist lpidlist&, zbuffer
        Function = zbuffer
    Else
        Function = ""
    End If
    End Function 
    '---------------------------------------------------------
    '------------------------------------------------------------------------------------------
    Function fbrowseproc(ByVal hwnd&,ByVal msg&,ByVal a&,ByVal startdir&)Export As Long
    Static zdir As Asciiz*%max_path
    Select Case msg&
        Case %bffm_initialized
            sendmessage hwnd&,%bffm_setselection,%true,startdir&
        Case %bffm_selchanged
            If shgetpathfromidlist(a&,ByVal VarPtr(zdir)) Then
                sendmessage hwnd&,%bffm_setstatustext,0,ByVal VarPtr(zdir)
            End If
    End Select
    Function = 0
    End Function
    '-----------------------------------------------------------------------------------------
    ------------------
    Scott
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    I seen it on w2000 creating a shortcut/browse..

    I think it's custom.

    ------------------
    hellobasic

    Comment


    • #3
      Some equates below. Try with %BIF_BROWSEINCLUDEFILES, works on Win98.

      Only thing weird is you get a treeview of all the files in the directoty, and an icon for "file type" at the node of the tree.

      Drop me a note if you want source with callback functions coded (DDT for the dialog).


      Code:
      '--------------------------------------------
      ' Declares for the "Browse for Folder" dialog
      '--------------------------------------------
      %BIF_RETURNONLYFSDIRS  = &H0001
      %BIF_DONTGOBELOWDOMAIN = &H0002
      %BIF_STATUSTEXT        = &H0004
      %BIF_RETURNFSANCESTORS = &H0008
      %BIF_BROWSEFORCOMPUTER = &H1000
      %BIF_BROWSEFORPRINTER  = &H2000
      %BIF_BROWSEINCLUDEFILES = &H4000  ' browses for files as well as folders
      %BIF_EDITBOX            = &H0010  ' provides user edit box to enter a folder/file
      %BIF_VALIDATE           = &H0020  ' only valid with %BIF_EDITBOX
                                        ' sends BFFM_VALIDATEFAILED to callback if edit box entry is invalid/
      
      %BFFM_INITIALIZED      = 1&
      %BFFM_SETSELECTIONA    = %WM_USER + 102&
      %BFFM_SELCHANGED       = 2&
      %BFFM_VALIDATEFAILEDA  =   3&   '// lParam:szPath ret:1(cont),0(EndDialog)
      %BFFM_VALIDATEFAILEDW  =   4&   '// lParam:wzPath ret:1(cont),0(EndDialog)
      %BFFM_SETSTATUSTEXTA   = %WM_USER + 100&


      ------------------
      Michael Mattias
      Racine WI USA
      [email protected]
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment

      Working...
      X