1 / 10

Common Dialog Boxes

Common Dialog Boxes. 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 Property

ravi
Download Presentation

Common Dialog Boxes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Common Dialog Boxes

  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 Method What it Does Result found in Property ShowOpen File Open Dialog .filename or .filetitle ShowSave File Save Dialog.filename or .filetitle ShowColor Color Selection Dialog .color ShowFont Font Selection dialog .fontname, .fontsize, ... ShowPrinter Printer Selection dialog .printerdefault ShowHelp Help Dialog .helpcontext, .help...

  3. 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

  4. 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)

  5. 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)

  6. 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)

  7. 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)

  8. 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)

  9. 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)

  10. 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)

More Related