|
-
Mar 31st, 2003, 11:19 AM
#1
Thread Starter
Fanatic Member
Font property not fully working
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:
Public Property Set Font(ByVal oFont As StdFont)
Debug.Print "1.Write Font Size: " & m_oFont.Size
With m_oFont
.Bold = oFont.Bold
.Charset = oFont.Charset
.Italic = oFont.Italic
.Name = oFont.Name
.Size = oFont.Size
.Strikethrough = oFont.Strikethrough
.Underline = oFont.Underline
.Weight = oFont.Weight
End With
PropertyChanged "Font"
Debug.Print "2.Write Font Size: " & m_oFont.Size
End Property
Public Property Get Font() As StdFont
Set Font = m_oFont
End Property
And here is my Property bag methods
VB Code:
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Font", m_oFont
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Debug.Print "1.Read Font Size: " & m_oFont.Size
m_oFont = PropBag.ReadProperty("Font")
Debug.Print "2.Read Font Size: " & m_oFont.Size
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
-
Mar 31st, 2003, 03:17 PM
#2
I think the problem is in the ReadProperties event. You are missing Set before m_oFont = PropBag... Since the Name property is the default for a Font object it is the only one being changed.
-
Mar 31st, 2003, 04:32 PM
#3
Thread Starter
Fanatic Member
Originally posted by brucevde
I think the problem is in the ReadProperties event. You are missing Set before m_oFont = PropBag... Since the Name property is the default for a Font object it is the only one being changed.
Thank you, that was infact the solution. I've never used the Font object before so I didnt think about the set.
Thanks again, i can finally continue with my control without getting annoyed
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|