Results 1 to 3 of 3

Thread: CommonDialog cancel problem (solved)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Belgium
    Posts
    77

    CommonDialog cancel problem (solved)

    Hi again, I have another strange prob with the Save box of my commondialog control. When I create a new file with it at the first lunch of my project it work fine and create it, but then if I lunch it again and click cancel button, it act like if I had press OK. It lunch my "file already exist" error even if I change the name in the save box before click cancel.

    CDialog1.DialogTitle = "Create a new databse"
    CDialog1.DefaultExt = "dtk"
    CDialog1.Filter = "DVD-ROM (*.dtk)|*.dtk |DVD-Video (*.dtv)|*.dtv"
    CDialog1.Flags = &H800
    CDialog1.CancelError = False
    CDialog1.ShowSave
    Test = CDialog1.FileTitle

    If Test = Dir(CDialog1.FileName) Then
    MsgBox ("The database already exist")
    Else
    Set dbs = CreateDatabase(CDialog1.FileName, dbLangGeneral, dbVersion30)
    Select Case CDialog1.FilterIndex
    Case 1
    Call createDVDROM
    Case 2
    Call createDVDVideo
    End Select
    End If

    I hope someone could help me, I am new with VB I started 2 days ago and I have got a lot of small problem of that kind
    Last edited by choas; Feb 21st, 2004 at 11:21 AM.

  2. #2
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236
    Thats because you have the CDialog1.CancelError = False

    VB Code:
    1. On Error GoTo ErrHandler
    2.  
    3. With CDialog1
    4.     .CancelError = True
    5.     .DefaultExt = "dtk"
    6.      'No need to check if the file exists
    7.     .Flags = cdlOFNOverwritePrompt + cdlOFNPathMustExist
    8.     .DialogTitle = "Create a new database"
    9.     .Filter = "DVD-ROM (*.dtk)|*.dtk |DVD-Video (*.dtv)|*.dtv"
    10.     .ShowSave
    11.     If .FileName = "" then Exit Sub
    12. End With
    13.  
    14. Set dbs = CreateDatabase(CDialog1.FileName, dbLangGeneral, dbVersion30)
    15. Select Case CDialog1.FilterIndex
    16. Case 1
    17. Call createDVDROM
    18. Case 2
    19. Call createDVDVideo
    20. End Select
    21. End If
    22.  
    23. Exit Sub
    24. ErrHandler:
    25. If Err <> cdlCancel Then
    26.     MsgBox Err.Description
    27. End If
    Last edited by Keithuk; Feb 21st, 2004 at 02:24 PM.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Belgium
    Posts
    77
    Thanks a lot, it work fine now. While I have got you, maybe u have a answer for my other problem with commondialog ?

    http://www.vbforums.com/showthread.p...hreadid=279810


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