The common dialog, contrary to some people’s beliefs, doesn’t actually do anything itself. It just is a easy to use pointer for other objects. The following dialogs can be show: ShowOpen, ShowSave, ShowColor, ShowFont, ShowPrinter, and ShowHelp.
The first step in the common dialog control is to include it in your project. To do this, go to Project > Components > Microsoft Common Dialog Control 6.0 (SP 3).
After this, you will see a little box in your control toolbox. Click this and drag it onto your form. The default name is CommonDialog1.
(i) Show Open
The ShowOpen dialog lists of files and folders on your computer.
By nikhil_07n at 2009-01-31
With CommonDialog1 'use this because we will have a lot of code with the box .DialogTitle = "Open" 'this sets the caption for the title bar on the dialog .InitDir = "D:\" 'this sets the initial director for the dialog box .Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" 'the filter property is what specifies which file types to display. The '(*.txt) is not necessary. 'as you can see, the file name comes first then the *.type comes 'next after the |. This is important .ShowOpen 'this event actually displays the open dialog box End With RichText1.LoadFile CommonDialog1.FileName 'NOTE :Rich text box is used!
The ShowSave dialog, as well as the ShowOpen, lists the files and folders of your computer. You can make new folders with this dialog.
By nikhil_07n at 2009-01-31
With CommonDialog1 'open a with statement as there is a lot of code .DialogTitle = "Save As" 'sets the dialog title .InitDir = "D:\" 'sets the initial directory .Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" 'sets the file 'types .ShowSave 'show the dialog End With RichText1.SaveFile CommonDialog1.FileName 'save to the specified file (iii)ShowColor The Color dialog box allows a user to select a color from the specified color palette, or they can even make their own custom color. Screen: [IMG]http://img207.imageshack.us/img207/894/colornb3.jpg[/IMG] By [URL=http://profile.imageshack.us/user/nikhil_07n]nikhil_07n[/URL] at 2009-01-31 Example: [code] With CommonDialog1 'open a with block .DialogTitle = "Color" 'set the title .ShowColor 'show the dialog End With Form1.BackColor = CommonDialog1.Color 'set the backcolor to the 'color selected
The Font Dialog box is the one with the most properties, but it is the most useful if you are making a text editor. (Or another app where the user needs to set the font.)
With CommonDialog1 'open the with dialog .DialogTitle = "Font" 'set the dialog title .Flags = cdlCFBoth Or cdlCFEffects 'set the flags so you can 'access the fonts* and the strikethru, underline, color .ShowFont 'show the dialog End With Richtext1.SelFontName = CommonDialog1.FontName 'set the selected font’s name Richtext1.SelFontSize = CommonDialog1.FontSize 'set the selected font’s size Richtext1.SelBold = CommonDialog1.FontBold 'set the selected font’s bold property Richtext1.SelItalic = CommonDialog1.FontItalic 'set the selected font’s italic property Richtext1.SelStrikeThru = CommonDialog1.FontStrikethru 'set the selected font’s strikethrough property Richtext1.SelUnderline = CommonDialog1.FontUnderline 'set the selected font’s underline property
To get more help , download the attachment, its a notepad created by me when i was beginner.
NOTE: It DOES NOT use ShowFont, ShowColor Options of Common DialoG box. I've created my own Font Selection.
Number of downloads: 2837