Results 1 to 3 of 3

Thread: CommonDialog

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    77

    Unhappy

    i am using commondialog to open files in directory so i have question how would i save that directory the user access last time so when user use the program again it will open the same directory which was accessed last.

  2. #2
    Hyperactive Member
    Join Date
    Nov 2000
    Location
    Mexico City
    Posts
    306

    Cool

    Take a look at this...

    Dim int_I As Integer

    dialog1.FileName = ""
    dialog1.DialogTitle = "Select the file"
    dialog1.DefaultExt = "Txt"
    dialog1.Filter = "All (*.*)|*.*|Text (*.txt)|*.txt"
    dialog1.InitDir = GetSetting("your app", "section", "setting", "default value")
    dialog1.Action = 1

    int_I = InStr(1, dialog1.FileName, dialog1.FileTitle)
    If int_I > 0 And Len(Trim$(dialog1.FileName)) > 0 Then
    SaveSetting "your app", "section", "setting", Left$(dialog1.FileName, int_I - 1)
    End If
    If things were easy, users might be programmers.

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'interuped before I could finish but seeing as I did it
    'I may as well post it..very similar to above except I use
    'a variable

    Code:
    Option Explicit
    
    Public myStoredDirName As String
    
    Private Sub Command1_Click()
    
    On Error GoTo out:
        CommonDialog1.CancelError = True
        CommonDialog1.InitDir = myStoredDirName                 'set dir path
        CommonDialog1.CancelError = True               'used in cancel code
        CommonDialog1.Filter = "All files(*.*)|*.*"    'filter for all files
        CommonDialog1.ShowOpen                         'show files
        myStoredDirName = CommonDialog1.FileName
        'open your file or whatever here
    out:
      'cancel was pressed
    End Sub
    Private Sub Form_Load()
    'this will load it into the register
      myStoredDirName = GetSetting("project1", "StringValue", "Value", 0)
    End Sub
    
    
    Private Sub Form_Unload(Cancel As Integer)
    'this will save it into the register when you quit
        SaveSetting "project1", "StringValue", "Value", myStoredDirName
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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