Results 1 to 8 of 8

Thread: Common Dialog Folder

  1. #1

    Thread Starter
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    Resolved Common Dialog Folder

    Is there a way to use the common dialog control to set a folder (not to open or save to file, just to get a folder's application path), or will I have to just code one on my own?
    Last edited by Nove; Oct 25th, 2004 at 08:12 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Yes, you can use some APIs to create a BrowseForFolder dialog.
    VB Code:
    1. Private Type BrowseInfo
    2.     hWndOwner As Long
    3.     pIDLRoot As Long
    4.     pszDisplayName As Long
    5.     lpszTitle As Long
    6.     ulFlags As Long
    7.     lpfnCallback As Long
    8.     lParam As Long
    9.     iImage As Long
    10. End Type
    11. Const BIF_RETURNONLYFSDIRS = 1
    12. Const MAX_PATH = 260
    13. Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
    14. Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    15. Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    16. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    17. Private Sub Form_Load()
    18.     'KPD-Team 1998
    19.     'URL: [url]http://www.allapi.net/[/url]
    20.     Dim iNull As Integer, lpIDList As Long, lResult As Long
    21.     Dim sPath As String, udtBI As BrowseInfo
    22.  
    23.     With udtBI
    24.         'Set the owner window
    25.         .hWndOwner = Me.hWnd
    26.         'lstrcat appends the two strings and returns the memory address
    27.         .lpszTitle = lstrcat("C:\", "")
    28.         'Return only if the user selected a directory
    29.         .ulFlags = BIF_RETURNONLYFSDIRS
    30.     End With
    31.  
    32.     'Show the 'Browse for folder' dialog
    33.     lpIDList = SHBrowseForFolder(udtBI)
    34.     If lpIDList Then
    35.         sPath = String$(MAX_PATH, 0)
    36.         'Get the path from the IDList
    37.         SHGetPathFromIDList lpIDList, sPath
    38.         'free the block of memory
    39.         CoTaskMemFree lpIDList
    40.         iNull = InStr(sPath, vbNullChar)
    41.         If iNull Then
    42.             sPath = Left$(sPath, iNull - 1)
    43.         End If
    44.     End If
    45.  
    46.     MsgBox sPath
    47. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736
    Thanks, that works absolutely great!

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    No prob. The site has allot of good examples on using APIs.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Lively Member
    Join Date
    Nov 2004
    Posts
    73

    browse to file

    RobDog888,

    The API folder browse sample code looks very good for me. But what I am looking for is folder and file browse. that means user can find some specific file through click the "Browse" button. Is there any API can handle that?

    Any help will be very appreciated!.

    Thanks,

    Robert Song

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Use the show files flag.
    VB Code:
    1. Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Lively Member
    Join Date
    Nov 2004
    Posts
    73
    Thank you so much, Rob. the constant woks perfectly.

    Robert

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    No prob.

    For all the API definitions, constants, and examples, downlod the
    API Viewer and API Guide from all api.net


    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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