article

A Guide To Common Dialog Boxes Including Fonts

Email
Submitted on: 1/23/2015 6:30:00 AM
By: Visualcode (from psc cd)  
Level: Intermediate
User Rating: By 16 Users
Compatibility: VB 6.0
Views: 1049
 
     This is for anyone who is having trouble with common dialog boxes. Common Dialogs I have seen many examples on pscode.com , that have messed up Common Dialogs , mainly when it comes to the font dialog. This tutorial should teach you all you need to know for common dialogs. Definitions: Flags - These are simply options or choices you can use. Using the flags: 'Setting it for use CommonDialog.Flags = &H1 'Setting it for use of more than one CommonDialog.Flags = &H1 Or &H4 Activating Dialogs: This is simply the code to start up each dialog box. CommonDialog.ShowColor 'Lets the user pick a color CommonDialog.ShowFont 'Lets the user pick font CommonDialog.ShowOpen 'Lets the user pick a file to open CommonDialog.ShowPrinter 'Shows Printer Setup CommonDialog.ShowSave 'Lets the user pick a file to save to ShowColor: The following are some flags for using the Color dialog boxes. &H1 - This is one i personally like. This makes the common dialog start showing its current color. &H2 - This starts with the custom color tab open. &H4 - This makes it so they can not create custom colors. &H8 - This adds a help button to the dialog. &H10 - This will reset the common dialog to default. ShowFont: The following are some flags for using the Font dialog boxes. &H1 - Allows the dialog only to list fonts supported by the system. &H2 - Allows the dialog only to list fonts supported by the printer. &H3 - Lists the fonts from the two above. &H4 - Adds a help button. &H100 - Allows the choices of underline strike thru and color selection. &H2000 - Shows only font sizes between the min and max. &H20000 - Allows only fonts that can be scaled. &H40000 - Allows only true type fonts Applying to a textbox - For each property you must set it here is an example that sets it assuming you have &H100 and have a textbox named Text1 Text1.FontName = CommonDialog.FontName Text1.FontItalic = CommonDialog.FontItalic Text1.FontBold = CommonDialog.FontBold Text1.FontStrikethru = CommonDialog.FontStrikethru Text1.FontUnderline = CommonDialog.FontUnderline Text1.FontSize = CommonDialog.FontSize Text1.ForeColor = CommonDialog.Color ShowOpen And ShowSave: The following are some flags for using the Open dialog boxes. &H2 - Forces a warning before overwriting a file &H8 - Stops default directory from changing &H10 - Shows help button. &H200 - This makes it so more than one file can be selected. &H1000 - This makes it so the file must exist. &H2000 - This warns the user before creating a new file. Opening a file: CommonDialog.ShowOpen Open CommonDialog.FileName for Input as #1 'Opens The File Do until Eof(1) "Loops till complete file added to Textbox Line Input #1, Tmp Text1.Text = Text1.Text & Tmp Loop Close #1 'Closes the file Saving a file: CommonDialog.ShowSave Open CommonDialog.FileName for Output as #1 'Opens The File Print #1, Text1.Text 'Creates The File Close #1 'Closes the file ShowPrinter: The following are some flags for using the Printer dialog boxes. &H4 - Makes it so they cant choose to print only selected text. &H8 - Does not allow you to choose to print certain pages like 4-7. &H800 - This shows the help button. &H40 - This shows the print setup dialog box rather than the printer dialog box. &H100000 - This gets rid of the print to file option box. Printing Landscape - Printer.Orientation = 2 Printing Portrait - Printer.Orientation = 1 Please vote and leave comments.
 
winzip iconDownload article

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.