Results 1 to 3 of 3

Thread: [RESOLVED] help with setting specific folder root

  1. #1

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Resolved [RESOLVED] help with setting specific folder root

    I am using the function below to open a folder selection window and what i want to do is make it select a specific directory as the root directory any help would be appreciated.

    this is the code
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const BIF_RETURNONLYFSDIRS = 1
    4. Private Const BIF_DONTGOBELOWDOMAIN = 2
    5. Private Const MAX_PATH = 260
    6.  
    7. Private Type BrowseInfo
    8.     hwndOwner      As Long
    9.     pIDLRoot       As Long
    10.     pszDisplayName As Long
    11.     lpszTitle      As Long
    12.     ulFlags        As Long
    13.     lpfnCallback   As Long
    14.     lParam         As Long
    15.     iImage         As Long
    16. End Type
    17.  
    18. Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    19.  
    20. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    21.  
    22. Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    23.  
    24. Public Function OpenDirectoryTV(Optional odtvTitle As String) As String
    25.     Dim lpIDList As Long
    26.     Dim sBuffer As String
    27.     Dim szTitle As String
    28.     Dim tBrowseInfo As BrowseInfo
    29.     szTitle = odtvTitle
    30.     With tBrowseInfo
    31.            .hwndOwner = frmUploader.hWnd
    32.            .lpszTitle = lstrcat(szTitle, "")
    33.            .ulFlags = BIF_RETURNONLYFSDIRS
    34.         End With
    35.     lpIDList = SHBrowseForFolder(tBrowseInfo)
    36.     If (lpIDList) Then
    37.         sBuffer = Space(MAX_PATH)
    38.         SHGetPathFromIDList lpIDList, sBuffer
    39.         sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
    40.         OpenDirectoryTV = sBuffer
    41.     End If
    42. End Function

    thanks in advance
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  2. #2
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: help with setting specific folder root

    Here is the code:
    VB Code:
    1. Private Const BIF_RETURNONLYFSDIRS As Long = &H1
    2.  
    3. Function BrowseFolder(Optional Caption As String, Optional InitialFolder As String) As String
    4. 'You need to set reference to Microsoft shell controls and automation
    5.     Dim SH As Shell32.Shell
    6.     Dim F As Shell32.Folder
    7.     Set SH = New Shell32.Shell
    8.     Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, InitialFolder)
    9.     If Not F Is Nothing Then
    10.         BrowseFolder = F.Items.Item.Path
    11.     End If
    12. End Function
    13.  
    14. 'How to call this function
    15. '    Dim FName As String
    16. '    FName = BrowseFolder("Select a folder to Insert Pictures", "C:\")
    CS

  3. #3

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: help with setting specific folder root

    Thanks a ton. Implemented it and it works great.. Rate up ^
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

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