common dialog boxes. there are 5 types of common dialogs which share a single common dialog control...
TRANSCRIPT
![Page 1: Common Dialog Boxes. There are 5 types of Common Dialogs which share a single Common Dialog Control Use one of the following methods to define the operation](https://reader035.vdocuments.site/reader035/viewer/2022071705/56649d015503460f949d334d/html5/thumbnails/1.jpg)
Common Dialog Boxes
![Page 2: Common Dialog Boxes. There are 5 types of Common Dialogs which share a single Common Dialog Control Use one of the following methods to define the operation](https://reader035.vdocuments.site/reader035/viewer/2022071705/56649d015503460f949d334d/html5/thumbnails/2.jpg)
Common Dialog Boxes
• There are 5 types of Common Dialogs which share a single Common Dialog Control
• Use one of the following methods to define the operation
Method What it Does Result found in PropertyShowOpen File Open Dialog .filename or .filetitleShowSave File Save Dialog .filename or .filetitle ShowColor Color Selection Dialog .colorShowFont Font Selection dialog .fontname, .fontsize, ...ShowPrinter Printer Selection dialog .printerdefaultShowHelp Help Dialog .helpcontext, .help...
![Page 3: Common Dialog Boxes. There are 5 types of Common Dialogs which share a single Common Dialog Control Use one of the following methods to define the operation](https://reader035.vdocuments.site/reader035/viewer/2022071705/56649d015503460f949d334d/html5/thumbnails/3.jpg)
Common Dialog Boxes (2)
• The common dialog control has no associated events • Initialize the properties before invoking the Showxxx
method• It is intended to be invoked with the dialogname.Showxxx
method • Use On Error goto with the cancelerror property set to
True to make the ESC key or Cancel Button abort the dialog
• Use the with … end with construct to simplify and clarify code
• Double Click (custom) for design time editor
![Page 4: Common Dialog Boxes. There are 5 types of Common Dialogs which share a single Common Dialog Control Use one of the following methods to define the operation](https://reader035.vdocuments.site/reader035/viewer/2022071705/56649d015503460f949d334d/html5/thumbnails/4.jpg)
Common Dialog Example
On Error GoTo dialogerror: ' so that errors (or esc or cancel) end the box
dlgOpenFile.InitDir = "C:\batch" ' the initial directory
dlgOpenFile.filename="" ' no file (in case cancel is pressed)
dlgOpenFile.CancelError = True ' cause an error if cancel button is pressed
'Filter spaces *ARE* significant - format is text1|mask1|text2|mask2...
dlgOpenFile.Filter = "Executables (*.exe)|*.exe|Com files (*.com)|*.com|Batch file(*.bat)|*.bat"
dlgOpenFile.FilterIndex = 3 ' choose the third filter item as the default
dlgOpenFile.DialogTitle = "Choose a program to open" ' title of dialog
dlgOpenFile.ShowOpen ' this is the open method
dialogerror: ' go here if there's an error (or the ESC key pressed)
![Page 5: Common Dialog Boxes. There are 5 types of Common Dialogs which share a single Common Dialog Control Use one of the following methods to define the operation](https://reader035.vdocuments.site/reader035/viewer/2022071705/56649d015503460f949d334d/html5/thumbnails/5.jpg)
Common Dialog Example (2)
With dlgOpenFile
On Error GoTo dialogerror: ' so that errors (or esc or cancel) end the box
.InitDir = "C:\batch" ' the initial directory
.filename="" ' no file (in case cancel is pressed)
.CancelError = True ' cause an error if cancel button is pressed
'Filter spaces *ARE* significant - format is "text1|mask1|text2|mask2…"
.Filter = "Executables (*.exe)|*.exe|Com files (*.com)|*.com|Batch File(*.bat)|*.bat"
.FilterIndex = 3 ' choose the third filter item as the default
.DialogTitle = "Choose a program to open" ' title of dialog
.ShowOpen ' this is the open method
end with
dialogerror: ' go here if there's an error (or the ESC key pressed)
![Page 6: Common Dialog Boxes. There are 5 types of Common Dialogs which share a single Common Dialog Control Use one of the following methods to define the operation](https://reader035.vdocuments.site/reader035/viewer/2022071705/56649d015503460f949d334d/html5/thumbnails/6.jpg)
Font Selection Dialog Box
• Font Dialog Properties– color, fontbold, fontitalic, fontstrikethru, fontunderline,
fontname, max, min, fontsize, flags, cancelerror
• Useful Font Dialog Flags– 2 cdlCFPrinterFonts (printer fonts only)– 1 cdlCFScreenFonts (screen fonts only)– 3 cdlCFBoth (all screen & printer
fonts)– 131072 cdlCFScalableOnly (Truetype fonts)– 32768 cdlCFWYSIWYG (both printer and screen)– 256 (enables font color selection)
![Page 7: Common Dialog Boxes. There are 5 types of Common Dialogs which share a single Common Dialog Control Use one of the following methods to define the operation](https://reader035.vdocuments.site/reader035/viewer/2022071705/56649d015503460f949d334d/html5/thumbnails/7.jpg)
Color Dialog Box
• Color Dialog Properties– color, flags, cancelerror
• Color Dialog Flags– 4 cdlCCPreventFullOpen (prevents user from defining own colors)
– 2 cdlCCFullOpen (starts dialog with custom color window open)
![Page 8: Common Dialog Boxes. There are 5 types of Common Dialogs which share a single Common Dialog Control Use one of the following methods to define the operation](https://reader035.vdocuments.site/reader035/viewer/2022071705/56649d015503460f949d334d/html5/thumbnails/8.jpg)
Open File Dialog Box
• OpenFile Dialog Properties– filename, filetitle, filter, filterindex, initdir,
maxfilesize, flags, cancelerror
• Openfile Dialog Flags– 512 cdlOFNAllowMultiSelect
(allows selection of multiple files)
– 4096 cdlOFNFileMustExist (user can only type in name of file that exists)
– 2 cdlOFNOverwritePrompt (Prompts user for overwrite if file exists in SaveAs)
![Page 9: Common Dialog Boxes. There are 5 types of Common Dialogs which share a single Common Dialog Control Use one of the following methods to define the operation](https://reader035.vdocuments.site/reader035/viewer/2022071705/56649d015503460f949d334d/html5/thumbnails/9.jpg)
Print Dialog Box
• Print Dialog Properties– Copies, frompage, max, min, printerdefault, topage,
flags, cancelerror
• Print Dialog Flags– 64 cdlPDPrintSetup
(Displays printer setup dialog instead of the print options dialog)
– 4 cdlPDNoSelection (Stops users from selecting print current selection)
– 1048576 cdlPDHidePrintToFile (Hides Print to File option)
![Page 10: Common Dialog Boxes. There are 5 types of Common Dialogs which share a single Common Dialog Control Use one of the following methods to define the operation](https://reader035.vdocuments.site/reader035/viewer/2022071705/56649d015503460f949d334d/html5/thumbnails/10.jpg)
Custom Dialog Boxes
• Really a form with the modal property set• You are free to use any type of control to
customize it to your needs• Does require extra machine resources since it is
another form• Often placed in a module so it can be used in a
variety of forms - use the name main for the subroutine if you want it to start your application (as in a login process)