VerySource

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 745|回复: 2

为什么我做的ActiveX控件的Font属性无法在属性窗口显示出来?

[复制链接]

2

主题

2

帖子

2.00

积分

新手上路

Rank: 1

积分
2.00
发表于 2020-1-3 15:30:01 | 显示全部楼层 |阅读模式
我做的控件由一个lable(名称为lblCaption)与一个timer组成,我用以下代码设置了控件的font属性:
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

但是Font属性无法在属性窗口显示出来,请问是什么原因?
整个代码可在这个地址下载:
http://www.vbgood.com/attachment.php?aid=5164

谢谢!!




回复

使用道具 举报

0

主题

34

帖子

17.00

积分

新手上路

Rank: 1

积分
17.00
发表于 2020-1-4 09:15:01 | 显示全部楼层
第一行代码改为这样,加NEW关键字
Private mfonFont As NEW StdFont
回复

使用道具 举报

0

主题

34

帖子

17.00

积分

新手上路

Rank: 1

积分
17.00
发表于 2020-1-4 09:21:01 | 显示全部楼层
Private mfonFont As New 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 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
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

快速回复 返回顶部 返回列表