|
-
Feb 21st, 2004, 07:06 AM
#1
Thread Starter
Lively Member
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.
-
Feb 21st, 2004, 08:01 AM
#2
Thats because you have the CDialog1.CancelError = False
VB Code:
On Error GoTo ErrHandler
With CDialog1
.CancelError = True
.DefaultExt = "dtk"
'No need to check if the file exists
.Flags = cdlOFNOverwritePrompt + cdlOFNPathMustExist
.DialogTitle = "Create a new database"
.Filter = "DVD-ROM (*.dtk)|*.dtk |DVD-Video (*.dtv)|*.dtv"
.ShowSave
If .FileName = "" then Exit Sub
End With
Set dbs = CreateDatabase(CDialog1.FileName, dbLangGeneral, dbVersion30)
Select Case CDialog1.FilterIndex
Case 1
Call createDVDROM
Case 2
Call createDVDVideo
End Select
End If
Exit Sub
ErrHandler:
If Err <> cdlCancel Then
MsgBox Err.Description
End If
Last edited by Keithuk; Feb 21st, 2004 at 02:24 PM.
-
Feb 21st, 2004, 08:35 AM
#3
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|