Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2004
    Location
    Earth, located in Milky Way galaxy
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Browseforfolders in Visual Basic

    The code below is a Browseforfolders script. It does what it is suppose to but the location always loses once the application is closed. I would like the user to specify one location or whatever and wants the form to remember the location previously chosen when it is open again....
    _____________________________
    Option Explicit

    Private Type BROWSEINFO
    hOwner As Long
    pidlRoot As Long
    pszDisplayName As String
    lpszTitle As String
    ulFlags As Long
    lpfn As Long
    lParam As Long
    iImage As Long
    End Type

    Private Const BIF_RETURNONLYFSDIRS = &H1
    Private Const BIF_DONTGOBELOWDOMAIN = &H2
    Private Const BIF_STATUSTEXT = &H4
    Private Const BIF_RETURNFSANCESTORS = &H8
    Private Const BIF_BROWSEFORCOMPUTER = &H1000
    Private Const BIF_BROWSEFORPRINTER = &H2000
    Private Const MAX_PATH = 260

    Private Declare Function SHGetPathFromIDList Lib "shell32" _
    Alias "SHGetPathFromIDListA" _
    (ByVal pidl As Long, _
    ByVal pszPath As String) As Long

    Private Declare Function SHBrowseForFolder Lib "shell32" _
    Alias "SHBrowseForFolderA" _
    (lpBrowseInfo As BROWSEINFO) As Long

    Private Declare Sub CoTaskMemFree Lib "ole32" _
    (ByVal pv As Long)



    Private Sub Command1_Click()

    Dim bi As BROWSEINFO
    Dim pidl As Long
    Dim path As String
    Dim pos As Long

    Label1.Caption = ""


    With bi
    .hOwner = Me.hWnd

    .pidlRoot = 0&

    .lpszTitle = "Select your Windows\System\ directory"

    .ulFlags = BIF_RETURNONLYFSDIRS
    End With

    pidl = SHBrowseForFolder(bi)
    path = Space$(MAX_PATH)

    If SHGetPathFromIDList(ByVal pidl, ByVal path) Then
    pos = InStr(path, Chr$(0))
    Label1.Caption = Left(path, pos - 1)
    End If

    Call CoTaskMemFree(pidl)

    End Sub
    ______________________

    and also how do i add this command to the form... being a newbie, i can't figure it out....the script is actually a part of my little program

    ______________________
    Private Sub Command1_Click()
    Bitmapfiletosave ("filename.ext")
    End Sub
    _______________
    You must dream to be a succesful person, go to sleep... www.niumai.tk is my site

  • #2
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use SaveSetting when you exit the program to save the information in the registry and GetSetting when you load to retrieve it from there.

    shmoove


  •  

    Posting Permissions

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