Hi

I have added a Font property to my active x control so developers can change the font using vb's properties window

To do this I have the following code..

VB Code:
  1. Public Property Set Font(ByVal oFont As StdFont)
  2.     Debug.Print "1.Write Font Size: " & m_oFont.Size
  3.     With m_oFont
  4.         .Bold = oFont.Bold
  5.         .Charset = oFont.Charset
  6.         .Italic = oFont.Italic
  7.         .Name = oFont.Name
  8.         .Size = oFont.Size
  9.         .Strikethrough = oFont.Strikethrough
  10.         .Underline = oFont.Underline
  11.         .Weight = oFont.Weight
  12.     End With
  13.    
  14.     PropertyChanged "Font"
  15.    
  16.     Debug.Print "2.Write Font Size: " & m_oFont.Size
  17. End Property
  18. Public Property Get Font() As StdFont
  19.     Set Font = m_oFont
  20. End Property

And here is my Property bag methods

VB Code:
  1. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  2.     PropBag.WriteProperty "Font", m_oFont
  3. End Sub
  4.  
  5. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  6.     Debug.Print "1.Read Font Size: " & m_oFont.Size
  7.     m_oFont = PropBag.ReadProperty("Font")
  8.     Debug.Print "2.Read Font Size: " & m_oFont.Size
  9. End Sub

now If i pop my control on my form and set a new font with the font dialog then click ok to confirm that font, the font is set to what i need.

But when i click run, all the font property values are reset except Font.Name

I dont understand why only the Font Name works, all the other attributes like bold, size, type etc reset to there default values.

Does anyone know why this is doing this to me?


Thanks