读书人

为什么小弟我做的ActiveX控件的Font属

发布时间: 2012-02-16 21:30:36 作者: rapoo

为什么我做的ActiveX控件的Font属性无法在属性窗口显示出来?
我做的控件由一个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

谢谢!!




[解决办法]
第一行代码改为这样,加NEW关键字
Private mfonFont As NEW StdFont

读书人网 >VB

热点推荐