Results 1 to 25 of 25

Thread: [RESOLVED] Open folder

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] Open folder

    I used commondialog. Why It open the files not the folder? I just want to show the folder not the files inside the folder

    Code:
    Private Sub Command1_Click()
    Dim shape As String
      shape = "ESRI Shapefiles (*.shp) |*.shp"
    
      CommonDialog1.CancelError = True
      On Error GoTo FileOpenCancel
      CommonDialog1.Filter = shape
      CommonDialog1.DialogTitle = "Lokasi Pangkalan data"
      CommonDialog1.ShowOpen
      outputfile = CommonDialog1.fileName
    FileOpenCancel:
      Exit Sub
     End Sub

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open folder

    It does that because that is what the common dialog is designed to do.

    If you don't want the files to be shown why are you adding a "shape" filter?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Open folder

    Oh, I no idea about how to point out the working directory location. I have create manually the directory let say in this location C:\Project\Database.. How I can select this location using browse or something that able me to search this location

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open folder

    You just want to browse for folders or do you just need to know if it exists?

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Open folder

    I have create the folder "database" first manually before run the VB.. let say I create the folder inside this directory C:\Project.

    How I can find this folder I have created using browse method? I have idea about using drivelistbox but I don't know how to used it

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open folder

    To browse for folders you can use something like
    Code:
    Private Const BIF_RETURNONLYFSDIRS = &H1       
    Private Const BIF_DONTGOBELOWDOMAIN = &H2       
    Private Const BIF_STATUSTEXT = &H4              
    Private Const BIF_RETURNFSANCESTORS = &H8
    Private Const BIF_EDITBOX = &H10                
    Private Const BIF_VALIDATE = &H20              
    Private Const BIF_BROWSEFORCOMPUTER = &H1000    
    Private Const BIF_BROWSEFORPRINTER = &H2000     
    Private Const BIF_BROWSEINCLUDEFILES = &H4000  
    
    Private Const MAX_PATH = 260
    
    Private Type T_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 Declare Function SHBrowseForFolder Lib "shell32" _
            (lpbi As T_BROWSEINFO) As Long
    
    Private Declare Function SHGetPathFromIDList Lib "shell32" _
            (ByVal pidList As Long, _
            ByVal lpBuffer As String) As Long
    
    Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" _
            (ByVal lpString1 As String, ByVal _
            lpString2 As String) As Long
    
    Public Function BrowseFolder(ByVal HwndOwner As Long, ByRef Titre As String) As String
    
        Dim lpIDList As Long
        Dim sBuffer As String
        Dim BrowseInfo As T_BROWSEINFO
    
        BrowseFolder = ""
        With BrowseInfo
            .HwndOwner = HwndOwner
            .lpszTitle = lstrcat(Titre, "")
            .ulFlags = BIF_RETURNONLYFSDIRS
        End With
    
        lpIDList = SHBrowseForFolder(BrowseInfo)
    
        If (lpIDList) Then
            sBuffer = Space(MAX_PATH)
            SHGetPathFromIDList lpIDList, sBuffer
            sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
            BrowseFolder = sBuffer
        End If
    End Function

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Open folder

    How I can use this function? What the object required?

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open folder

    Just do something like
    Code:
    BrowseFolder Me.hWnd, "My Folder List"

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Open folder

    Thank you so much!!!!.

    How it can show the selected folder location in the textbox?

    Private Sub Command1_Click()
    BrowseFolder Me.hWnd, "My Folder List"
    End Sub

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Open folder

    After select the folder, I click ok..

    How I can get the "corrupt shp" path location? and show it in the textbox
    Attached Images Attached Images  

  11. #11

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Open folder

    Hi, Hack.. How I can modify this title "Browse for folder" to another name?

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open folder

    Quote Originally Posted by matrik02
    Hi, Hack.. How I can modify this title "Browse for folder" to another name?
    I don't understand what you mean.

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: [RESOLVED] Open folder

    How to change this title name "Browse for folder" to another name
    Attached Images Attached Images  

  15. #15
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: [RESOLVED] Open folder

    I think he means change the Title bar text of the dialog, tho not sure why anyone would want to change it, it is a "browse for folder" dialog, why confuse things by changing it?

  16. #16

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: [RESOLVED] Open folder

    Because I want to change to my local language

  17. #17
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [RESOLVED] Open folder

    How do I add a "new folder" to the left of the OK and Cancel buttons?
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  18. #18

  19. #19
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [RESOLVED] Open folder

    Many thanks :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  20. #20
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [RESOLVED] Open folder

    Hmmm, I added it in the same section as similar lines (those that started "Private Const BIF_") and it doesn't seem to make a difference, I still don't get a "new folder" icon :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  21. #21
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: [RESOLVED] Open folder

    Your list of flags may look like this:
    Code:
    Private Const BIF_RETURNONLYFSDIRS = 1
    Private Const BIF_DONTGOBELOWDOMAIN = 2
    Private Const BIF_EDITBOX = &H10
    Private Const BIF_VALIDATE = &H20
    Private Const BIF_NEWDIALOGSTYLE = &H40
    Private Const BIF_BROWSEFORCOMPUTER = &H1000
    
    '-------------------
    
        With tBrowseInfo
            .hWndOwner = Me.hWnd
            .ulFlags = BIF_RETURNONLYFSDIRS & BIF_DONTGOBELOWDOMAIN & _
                       BIF_EDITBOX & BIF_VALIDATE & BIF_NEWDIALOGSTYLE & _
                       BIF_BROWSEFORCOMPUTER
        End With

  22. #22
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [RESOLVED] Open folder

    I am using the exact same code as listed near the top by Hack.

    It has ".ulFlags = BIF_RETURNONLYFSDIRS" which I replaced with ".ulFlags = BIF_RETURNONLYFSDIRS & BIF_NEWDIALOGSTYLE" and it hasn't made any difference...BIF_NEWDIALOGSTYLE is in the list of CONSTs.

    This is all stuff I've not done before, as you can guess :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  23. #23
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: [RESOLVED] Open folder

    Sorry, my mistake - you need to use th OR operator. Also, for simplicity you may declare another const that is a combination of several other:
    Code:
    Private Const BIF_SHOWMAKENEW As Long = (BIF_NEWDIALOGSTYLE Or BIF_EDITBOX)
    
        With tBrowseInfo
            .hWndOwner = Me.hWnd
            .ulFlags = BIF_RETURNONLYFSDIRS
            .ulFlags = .ulFlags Or BIF_SHOWMAKENEW
        End With
    That should do it.

  24. #24
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [RESOLVED] Open folder

    Under the browseinfo (tBrowseInfo in your example) I changed the AND to OR so it read ".ulFlags = BIF_RETURNONLYFSDIRS Or BIF_NEWDIALOGSTYLE" and that worked fine first time...many thanks :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  25. #25

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