btz中国设计秀
Shape1.BackColor = RGB(255, 0, 0)
btz中国设计秀
End Sub
btz中国设计秀
btz中国设计秀
Property Get PosX() As Integer '取得CircleX的值显示给用户
btz中国设计秀
PosX = CircleX
btz中国设计秀
End Property
btz中国设计秀
btz中国设计秀
Property Let PosX(ByVal New_X As Integer) '把用户写入的值设置到OCX控件内部
btz中国设计秀
If (New_X < Shape1.Width / 2) Or _
btz中国设计秀
(New_X > UserControl.ScaleWidth - Shape1.Width / 2) Then
btz中国设计秀
MsgBox ("圆的X值超出界限了")
btz中国设计秀
Else
btz中国设计秀
CircleX = New_X
btz中国设计秀
Call UserControl_Resize
btz中国设计秀
End If
btz中国设计秀
End Property
btz中国设计秀
btz中国设计秀
Property Get PosY() As Integer
btz中国设计秀
PosY = CircleY
btz中国设计秀
End Property
btz中国设计秀
btz中国设计秀
Property Let PosY(ByVal New_Y As Integer)
btz中国设计秀
If (New_Y < Shape1.Height / 2) Or _
btz中国设计秀
(New_Y > UserControl.ScaleHeight - Shape1.Height / 2) Then
btz中国设计秀
MsgBox ("圆的Y值超出界限了")
btz中国设计秀
Else
btz中国设计秀
CircleY = New_Y
btz中国设计秀
Call UserControl_Resize
btz中国设计秀
End If
btz中国设计秀
End Property
btz中国设计秀
btz中国设计秀
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
btz中国设计秀
CircleX = PropBag.ReadProperty("CircleX", Shape1.Width / 2) '将用户设置的值读出来
btz中国设计秀
CircleY = PropBag.ReadProperty("CircleY", Shape1.Height / 2) '同上
btz中国设计秀
Call UserControl_Resize
btz中国设计秀
End Sub
btz中国设计秀
btz中国设计秀
Private Sub UserControl_Resize()
btz中国设计秀
Shape1.Move CircleX, CircleY
btz中国设计秀
End Sub
btz中国设计秀
btz中国设计秀
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
btz中国设计秀
Call PropBag.WriteProperty("CircleX", CircleX, Shape1.Width / 2) '将用户设置的值保存
btz中国设计秀
Call PropBag.WriteProperty("CircleY", CircleY, Shape1.Height / 2) '同上
btz中国设计秀
End Sub
btz中国设计秀
btz中国设计秀
麻雀虽小,五脏俱全。这个OCX控件完成的任务虽然简单,但是OCX控件的基本操作全都有喔! 有兴趣的朋友不妨一试。
btz中国设计秀
btz中国设计秀