|
-
July 5th, 2001, 03:01 PM
#1
Common Dialog Handling a cancel
I am working with several of the common dialog forms. My question is regarding the cancel. I am surprised that the dialogs don't set an attribute that the form was cancelled and believe I am missing something easy.
I have written the following to catch the error code but I am unsure if this is the best or even appropriate way to handle this.
I believe the Microsoft example has the code checking the filename after the execution of the dialog to see if a filename is returned. Unfortunately this doesn't seem to work if you are providing a default file for the dialog.
private Function OpenCommonDialog(sFileName as string) as string
'Work around to determine if the cancel button was clicked on the
' common dialog. The dialog doesn't set an attribute. You must
' catch the exception. Thanks Microsoft! Hence the seperate function
' for this purpose.
on error GoTo ErrorHandler:
'Perform the file write here
'prompt for the file location.
dlgBrowseFile.Flags = cdlOFNOverwritePrompt & cdlOFNPathMustExist
dlgBrowseFile.InitDir = sFileName
dlgBrowseFile.Filter = "All Text (*.txt)|*.txt"
dlgBrowseFile.DefaultExt = "REV"
dlgBrowseFile.CancelError = true
dlgBrowseFile.ShowSave
sFileName = dlgBrowseFile.filename
End1:
OpenCommonDialog = sFileName
Exit Function
ErrorHandler:
sFileName = ""
resume End1:
End Function
Thanks EveryOne
All comments welcome...
(I'll do anything to avoid the goto statement!)
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
|