'CIS 230 Ch 5 Demo 1 'Mr. Minich 'This program demonstrates the use of the Color and Font dialog boxes (see pp. 177-181). You need to place ' the common dialog control on your form in order to use these dialog boxes. If you do not see the common ' dialog control in your toolbox, you must click the Projects/Components menu command and place a check next ' to the item called "Microsoft Common Dialog Control 6.0". Use the prefix "dlg" when you name the common dialog ' control in your project or simply use the name "dlgCommon". Option Explicit Private Sub mnuEditFont_Click() 'Displays the common dialog box to change the font 'properties of a label. With dlgCommon .FontName = lblLabel.Font.Name 'set initial font properties of font dialog box .FontBold = lblLabel.Font.Bold ' to those of the label .FontItalic = lblLabel.Font.Italic .FontSize = lblLabel.Font.Size .Flags = cdlCFScreenFonts 'necessary to specify screen fonts .ShowFont 'display the dialog box End With With lblLabel.Font .Name = dlgCommon.FontName 'change the font properties of the label to those .Bold = dlgCommon.FontBold ' selected in the font dialog box .Italic = dlgCommon.FontItalic .Size = dlgCommon.FontSize End With End Sub Private Sub mnuEditColor_Click() 'Displays the common dialog box to change the foreground 'color of a label With dlgCommon .Flags = cdlCCRGBInit 'necessary to initialize the dialog box .Color = lblLabel.ForeColor 'set initial color to the current ForeColor of the label .ShowColor 'display dialog box lblLabel.ForeColor = .Color 'setting the new chosen color to the label's ForeColor End With End Sub