| |

VerySource

 Forgot password?
 Register
Search
View: 748|Reply: 2

Why can't the Font property of my ActiveX control be displayed in the properties window?

[Copy link]

2

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-3 15:30:01
| Show all posts |Read mode
The control I made consists of a lable (named lblCaption) and a timer.I set the control's font property with the following code:
Private mfonFont As StdFont

Public Property Get Font () As StdFont
'the value for the control's font property is "stored" in the lblcaption object's font property
Set Font = lblCaption.Font
End Property

Public Property Set Font (ByVal NewValue As Variant)
'store the control's new font value in the lblcaption object's font property
Set lblCaption.Font = NewValue
UserControl.PropertyChanged "Font"
End Property

Private Sub UserControl_WriteProperties (PropBag As PropertyBag)
PropBag.WriteProperty "Font", Font, mfonFont
End Sub

Private Sub UserControl_ReadProperties (PropBag As PropertyBag)
Set Font = PropBag.ReadProperty ("Font", mfonFont)
End Sub

However, the Font property cannot be displayed in the property window. What is the reason?
The entire code can be downloaded at this address:
http://www.vbgood.com/attachment.php?aid=5164

Thank you!!
Reply

Use magic Report

0

Threads

34

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-1-4 09:15:01
| Show all posts
The first line of code is changed to this, adding the NEW keyword
Private mfonFont As NEW StdFont
Reply

Use magic Report

0

Threads

34

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-1-4 09:21:01
| Show all posts
Private mfonFont As New StdFont 'change it here

Public Property Get Font () As StdFont
'the value for the control's font property is "stored" in the lblcaption object's font property
Set Font = lblCaption.Font
End Property

Public Property Set Font (ByVal NewValue As StdFont) '
'store the control's new font value in the lblcaption object's font property
Set lblCaption.Font = NewValue
UserControl.PropertyChanged "Font"
End Property

Private Sub UserControl_WriteProperties (PropBag As PropertyBag)
PropBag.WriteProperty "Font", Font, mfonFont
End Sub

Private Sub UserControl_ReadProperties (PropBag As PropertyBag)
Set Font = PropBag.ReadProperty ("Font", mfonFont)
End Sub
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list