MarkG
10-31-2000, 10:57 AM
I'm attempting to create a new command button control from the existing command button control that will allow the user to change the color of the font. I've added the ForeColor property and defined its persistence. Obviously I'm missing something - the font color stays black. Here is a part of my code:
Const m_def_ForeColor = vbBlue
Dim m_ForeColor As OLE_COLOR
Public Property Get ForeColor() As OLE_COLOR
ForeColor = m_ForeColor
End Property
Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
m_ForeColor = New_ForeColor
PropertyChanged "ForeColor"
End Property
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
cmdGuru.BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
m_ForeColor = PropBag.ReadProperty("ForeColor", m_def_ForeColor)
cmdGuru.Enabled = PropBag.ReadProperty("Enabled", True)
Set cmdGuru.Font = PropBag.ReadProperty("Font", Ambient.Font)
m_BackStyle = PropBag.ReadProperty("BackStyle", m_def_BackStyle)
m_BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle)
cmdGuru.Caption = PropBag.ReadProperty("Caption", "")
cmdGuru.FontUnderline = PropBag.ReadProperty("FontUnderline", 0)
m_FontTransparent = PropBag.ReadProperty("FontTransparent", m_def_FontTransparent)
cmdGuru.FontStrikethru = PropBag.ReadProperty("FontStrikethru", 0)
cmdGuru.FontSize = PropBag.ReadProperty("FontSize", 0)
cmdGuru.FontName = PropBag.ReadProperty("FontName", "")
cmdGuru.FontItalic = PropBag.ReadProperty("FontItalic", 0)
cmdGuru.FontBold = PropBag.ReadProperty("FontBold", 0)
Set m_Image = PropBag.ReadProperty("Image", Nothing)
cmdGuru.MaskColor = PropBag.ReadProperty("MaskColor", 12632256)
cmdGuru.MousePointer = PropBag.ReadProperty("MousePointer", 0)
Set MouseIcon = PropBag.ReadProperty("MouseIcon", Nothing)
Set Picture = PropBag.ReadProperty("Picture", Nothing)
cmdGuru.ToolTipText = PropBag.ReadProperty("ToolTipText", "")
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("BackColor", cmdGuru.BackColor, &H8000000F)
Call PropBag.WriteProperty("ForeColor", m_ForeColor, m_def_ForeColor)
Call PropBag.WriteProperty("Enabled", cmdGuru.Enabled, True)
Call PropBag.WriteProperty("Font", cmdGuru.Font, Ambient.Font)
Call PropBag.WriteProperty("BackStyle", m_BackStyle, m_def_BackStyle)
Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle)
Call PropBag.WriteProperty("Caption", cmdGuru.Caption, "")
Call PropBag.WriteProperty("FontUnderline", cmdGuru.FontUnderline, 0)
Call PropBag.WriteProperty("FontTransparent", m_FontTransparent, m_def_FontTransparent)
Call PropBag.WriteProperty("FontStrikethru", cmdGuru.FontStrikethru, 0)
Call PropBag.WriteProperty("FontSize", cmdGuru.FontSize, 0)
Call PropBag.WriteProperty("FontName", cmdGuru.FontName, "")
Call PropBag.WriteProperty("FontItalic", cmdGuru.FontItalic, 0)
Call PropBag.WriteProperty("FontBold", cmdGuru.FontBold, 0)
Call PropBag.WriteProperty("Image", m_Image, Nothing)
Call PropBag.WriteProperty("MaskColor", cmdGuru.MaskColor, 12632256)
Call PropBag.WriteProperty("MousePointer", cmdGuru.MousePointer, 0)
Call PropBag.WriteProperty("MouseIcon", MouseIcon, Nothing)
Call PropBag.WriteProperty("Picture", Picture, Nothing)
Call PropBag.WriteProperty("ToolTipText", cmdGuru.ToolTipText, "")
End Sub
What am I missing?
Thanks for the help!
Const m_def_ForeColor = vbBlue
Dim m_ForeColor As OLE_COLOR
Public Property Get ForeColor() As OLE_COLOR
ForeColor = m_ForeColor
End Property
Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
m_ForeColor = New_ForeColor
PropertyChanged "ForeColor"
End Property
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
cmdGuru.BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
m_ForeColor = PropBag.ReadProperty("ForeColor", m_def_ForeColor)
cmdGuru.Enabled = PropBag.ReadProperty("Enabled", True)
Set cmdGuru.Font = PropBag.ReadProperty("Font", Ambient.Font)
m_BackStyle = PropBag.ReadProperty("BackStyle", m_def_BackStyle)
m_BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle)
cmdGuru.Caption = PropBag.ReadProperty("Caption", "")
cmdGuru.FontUnderline = PropBag.ReadProperty("FontUnderline", 0)
m_FontTransparent = PropBag.ReadProperty("FontTransparent", m_def_FontTransparent)
cmdGuru.FontStrikethru = PropBag.ReadProperty("FontStrikethru", 0)
cmdGuru.FontSize = PropBag.ReadProperty("FontSize", 0)
cmdGuru.FontName = PropBag.ReadProperty("FontName", "")
cmdGuru.FontItalic = PropBag.ReadProperty("FontItalic", 0)
cmdGuru.FontBold = PropBag.ReadProperty("FontBold", 0)
Set m_Image = PropBag.ReadProperty("Image", Nothing)
cmdGuru.MaskColor = PropBag.ReadProperty("MaskColor", 12632256)
cmdGuru.MousePointer = PropBag.ReadProperty("MousePointer", 0)
Set MouseIcon = PropBag.ReadProperty("MouseIcon", Nothing)
Set Picture = PropBag.ReadProperty("Picture", Nothing)
cmdGuru.ToolTipText = PropBag.ReadProperty("ToolTipText", "")
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("BackColor", cmdGuru.BackColor, &H8000000F)
Call PropBag.WriteProperty("ForeColor", m_ForeColor, m_def_ForeColor)
Call PropBag.WriteProperty("Enabled", cmdGuru.Enabled, True)
Call PropBag.WriteProperty("Font", cmdGuru.Font, Ambient.Font)
Call PropBag.WriteProperty("BackStyle", m_BackStyle, m_def_BackStyle)
Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle)
Call PropBag.WriteProperty("Caption", cmdGuru.Caption, "")
Call PropBag.WriteProperty("FontUnderline", cmdGuru.FontUnderline, 0)
Call PropBag.WriteProperty("FontTransparent", m_FontTransparent, m_def_FontTransparent)
Call PropBag.WriteProperty("FontStrikethru", cmdGuru.FontStrikethru, 0)
Call PropBag.WriteProperty("FontSize", cmdGuru.FontSize, 0)
Call PropBag.WriteProperty("FontName", cmdGuru.FontName, "")
Call PropBag.WriteProperty("FontItalic", cmdGuru.FontItalic, 0)
Call PropBag.WriteProperty("FontBold", cmdGuru.FontBold, 0)
Call PropBag.WriteProperty("Image", m_Image, Nothing)
Call PropBag.WriteProperty("MaskColor", cmdGuru.MaskColor, 12632256)
Call PropBag.WriteProperty("MousePointer", cmdGuru.MousePointer, 0)
Call PropBag.WriteProperty("MouseIcon", MouseIcon, Nothing)
Call PropBag.WriteProperty("Picture", Picture, Nothing)
Call PropBag.WriteProperty("ToolTipText", cmdGuru.ToolTipText, "")
End Sub
What am I missing?
Thanks for the help!