在vb怎样解决用commondialog设定字体设计时弹出没有安装字体的问题
在调式的时候弹出字体对话框,说没有安装字体,请从控制面板 
打开“字体”文件夹以便安装字体!请问怎么才能解决字体安装问题?
C:\WINDOWS\Fonts里面打开看了也有好多字体类型
我那段代码是这样的,不知道是对的不,请各位多多指教....(我是在PICTUREBOX上直接加了个TXT)
Private Sub Command7_Click()
CommonDialog1.ShowFont
Picture1.Font = CommonDialog1.FontName
End Sub还有就是 如果我想改变字体的颜色又应该怎么办呢?
下面这段是改变画出的图形的颜色
Private Sub Command1_Click()
  CommonDialog1.ShowColor
  Picture1.ForeColor = CommonDialog1.Color
End Sub

解决方案 »

  1.   


    Option Explicit
        Dim c As Long
        Dim red As Byte
        Dim green As Byte
        Dim blue As Byte
    Private Sub Command1_Click()
        CommonDialog1.CancelError = True
        CommonDialog1.DialogTitle = "颜色"
        CommonDialog1.ShowColor
        c = CommonDialog1.Color
        red = (c And &HFF)
        green = (c And 62580) / 256
        blue = (c And &HFF00) / 65536
        Picture1.FontSize = 36
        Picture1.ForeColor = RGB(red, green, blue)
        Picture1.Print "Color"
    End Sub
      

  2.   

    修改BUGOption Explicit
        Dim c As Long
        Dim red As Byte
        Dim green As Byte
        Dim blue As Byte
    Private Sub Command1_Click()
        CommonDialog1.CancelError = True
        CommonDialog1.DialogTitle = "颜色"
        CommonDialog1.ShowColor
        c = CommonDialog1.Color
        red = (c Mod 65536) Mod 256 'Red
        green = (c Mod 65536) \ 256 'Green
        blue = c \ 65536 'Blue
        Picture1.FontSize = 36
        Picture1.ForeColor = RGB(red, green, blue)
        Picture1.Print "Color"
    End Sub
      

  3.   

    Option Explicit
        Dim c As Long
        Dim red As Byte
        Dim green As Byte
        Dim blue As Byte
    Private Sub Command1_Click()
        CommonDialog1.CancelError = True
        CommonDialog1.DialogTitle = "颜色"
        CommonDialog1.ShowColor
        c = CommonDialog1.Color
        red = (c Mod 65536) Mod 256 'Red
        green = (c Mod 65536) \ 256 'Green
        blue = c \ 65536 'Blue
        FontXz
        Picture1.ForeColor = RGB(red, green, blue)
        Picture1.Print "Color"
    End SubPrivate Sub FontXz()
        ' 设置“取消”为 True
        CommonDialog1.CancelError = True
        On Error GoTo ErrHandler
        ' 设置 Flags 属性
        CommonDialog1.Flags = cdlCFEffects Or cdlCFBoth
        ' 显示“字体”对话框
        CommonDialog1.ShowFont
        Picture1.Font.Name = CommonDialog1.FontName
        Picture1.Font.Size = CommonDialog1.FontSize
        Picture1.Font.Bold = CommonDialog1.FontBold
        Picture1.Font.Italic = CommonDialog1.FontItalic
        Picture1.Font.Underline = CommonDialog1.FontUnderline
        Picture1.FontStrikethru = CommonDialog1.FontStrikethru
        Picture1.ForeColor = CommonDialog1.Color
        Exit Sub
    ErrHandler:
        ' 用户按了“取消”按钮
        Exit Sub
    End Sub