详细,点击控件属性页就提示错误。'这是用户控件ctl代码Dim labelCount As Integer
Dim labelActive As Integer
Dim labelAim As IntegerDim labelActHeight As Integer
Dim labelDelableHeight As Integer
Dim labelBlank As Integer
Dim labelHeight As IntegerDim Width As Integer, Height As Integer
Dim TabBackColor As LongDim ActiveBlod As Boolean
Dim InactiveItalic As Boolean
Const lineColor = &HE7DAAE
Const ControlSpace = 10000
Const BlankSpace = 10
Private Type labelData
Caption As String
Width As Integer
Left As Integer
End Type
Dim myLabel() As labelDataPublic Event TabSwitch(ByVal LastActiveTab As Integer)
Public Property Get FontBlod() As Boolean
FontBlod = ActiveBlod
End Property
Public Property Let FontBlod(ByVal vNewValue As Boolean)
ActiveBlod = vNewValue
Call Refresh
End Property
Public Property Get FontItalic() As Boolean
FontItalic = InactiveItalic
End Property
Public Property Let FontItalic(ByVal vNewValue As Boolean)
InactiveItalic = vNewValue
Call Refresh
End Property
Public Property Get BackColor() As OLE_COLOR
BackColor = TabBackColor
End PropertyPublic Property Let BackColor(ByVal vNewValue As OLE_COLOR)
TabBackColor = vNewValue
skin.Line (0, 0)-(3, 0), vNewValue
skin.Line (0, 1)-(2, 1), vNewValue
skin.PSet (0, 2), vNewValue
skin.Line (0, 24)-(3, 24), vNewValue
skin.Line (0, 25)-(2, 25), vNewValue
skin.PSet (0, 26), vNewValue
skin.Line (77, 0)-(80, 0), vNewValue
skin.Line (78, 1)-(80, 1), vNewValue
skin.PSet (79, 2), vNewValue
skin.Line (77, 24)-(80, 24), vNewValue
skin.Line (78, 25)-(80, 25), vNewValue
skin.PSet (79, 26), vNewValue
skin.Refresh
UserControl.BackColor = vNewValue
Call Refresh
End Property
Public Property Get ActiveTab() As Integer
ActiveTab = labelActive
End Property
Public Property Let ActiveTab(ByVal vNewValue As Integer)
Dim LastActive As Integer
If vNewValue < 0 Then vNewValue = 0
If vNewValue >= labelCount Then vNewValue = labelCount - 1
If labelActive <> vNewValue Then
LastActive = labelActive
labelActive = vNewValue
RaiseEvent TabSwitch(LastActive)
Call Refresh
Call ControlRefresh(LastActive)
End If
End Property
Public Property Get Caption() As String
Caption = myLabel(labelActive).Caption
End Property
Public Property Let Caption(ByVal vNewValue As String)
Label1.Caption = vNewValue
With myLabel(labelActive)
.Caption = vNewValue
.Width = Label1.Width + BlankSpace * 2
If .Width < 80 Then .Width = 80
.Left = (.Width - Label1.Width) / 2
End With
Call Refresh
End Property
Public Property Get TabCount() As Integer
TabCount = labelCount
End Property
Public Property Let TabCount(ByVal vNewValue As Integer)
Dim i As Integer, LastActive As Integer
If labelCount = vNewValue Then Exit Property
ReDim Preserve myLabel(vNewValue - 1)
For i = labelCount To vNewValue - 1
myLabel(i).Width = 80
Next
labelCount = vNewValue
LastActive = labelActive
If labelActive > labelCount - 1 Then
labelActive = labelCount - 1
RaiseEvent TabSwitch(LastActive)
Call ControlRefresh(LastActive)
End If
Call Refresh
End PropertyPrivate Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'X = X \ 15
'Y = Y \ 15
Dim i As Integer, Left As Integer, LastActive As Integer
Left = 1
For i = 0 To labelCount - 1
Left = Left + labelBlank
If labelActive <> i And X >= Left And X <= Left + myLabel(i).Width - 1 And Y >= 9 And Y <= labelHeight + 1 Then
LastActive = labelActive
labelActive = i
RaiseEvent TabSwitch(LastActive)
Call Refresh
Call ControlRefresh(LastActive)
Exit For
End If
Left = Left + myLabel(i).Width
Next
End Sub
Private Sub ControlRefresh(LastActive As Integer)
Dim Ctl As Control, MoveVal As Single
If LastActive = labelActive Then Exit Sub
MoveVal = CSng(labelActive - LastActive) * ControlSpace
For Each Ctl In UserControl.ContainedControls
Ctl.Left = Ctl.Left + MoveVal
Next Ctl
End Sub
Public Sub Refresh()
Dim Left As Integer
Left = 1
UserControl.Cls
Line (0, labelHeight + 1)-(Width - 1, Height - 1), &HFFFFFF, BF
For i = 0 To labelCount - 1
Line (Left, labelHeight + 1)-(Left + labelBlank, labelHeight + 1), lineColor
Left = Left + labelBlank
If labelActive = i Then '活动页
UserControl.PaintPicture skin.Image, Left, labelHeight - labelActHeight + 1, myLabel(i).Width, 5, 0, 24, 80, 5
UserControl.PaintPicture skin.Image, Left, labelHeight - labelActHeight + 6, myLabel(i).Width, labelActHeight - 5, 0, 29, 80, 24
Line (Left, 6)-(Left, labelHeight + 2), lineColor
Line (Left + myLabel(i).Width - 1, 6)-(Left + myLabel(i).Width - 1, labelHeight + 2), lineColor
Line (Left + 1, labelHeight + 1)-(Left + myLabel(i).Width - 1, labelHeight + 1), &HFFFFFF
UserControl.CurrentX = Left + myLabel(i).Left
UserControl.CurrentY = 12
UserControl.FontBold = FontBold
UserControl.FontItalic = False
UserControl.Print myLabel(i).Caption
Else
UserControl.PaintPicture skin.Image, Left, labelHeight - labelDelableHeight + 1, myLabel(1).Width, 6, 0, 0, 80, 6
UserControl.PaintPicture skin.Image, Left, labelHeight - labelDelableHeight + 7, myLabel(i).Width, labelDelableHeight - 6, 0, 6, 80, 18
Line (Left, 9)-(Left, labelHeight + 1), lineColor
Line -(Left + myLabel(i).Width - 1, labelHeight + 1), lineColor
Line -(Left + myLabel(i).Width - 1, 9), lineColor
UserControl.CurrentX = Left + myLabel(i).Left
UserControl.CurrentY = 13
UserControl.FontBold = False
UserControl.FontItalic = FontItalic
UserControl.Print myLabel(i).Caption
End If
Left = Left + myLabel(i).Width
Next
Line (Left, labelHeight + 1)-(Width - 1, labelHeight + 1), lineColor
Line -(Width - 1, Height - 1), lineColor
Line -(0, Height - 1), lineColor
Line -(0, labelHeight), lineColor
UserControl.Refresh
End Sub
Private Sub UserControl_Initialize()
labelCount = 3
ReDim myLabel(labelCount - 1)
Dim i As Integer
labelActive = 0
labelAim = -1
For i = 0 To labelCount - 1
myLabel(i).Width = 80
Next
TabBackColor = &HFFFFFF
labelActHeight = 29
labelDelableHeight = 24
labelHeight = 29
labelBlank = 4
End SubPrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)
Dim temp As String
TabCount = PropBag.ReadProperty("tabcount", 3)
ReDim Preserve myLabel(TabCount - 1)
For labelActive = 0 To labelCount - 1
temp = "caption" & Trim$(Str$(labelActive))
Caption = PropBag.ReadProperty(temp, "")
Next
ActiveTab = PropBag.ReadProperty("ActiveTab", 0)
BackColor = PropBag.ReadProperty("backcolor", &H8000000F)
FontBlod = PropBag.ReadProperty("fontblod", False)
FontItalic = PropBag.ReadProperty("fontitalic", False)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Dim temp As String, tempActive As Integer
tempActive = labelActive
Call PropBag.WriteProperty("tabcount", labelCount, 3)
For labelActive = 0 To labelCount - 1
temp = "caption" & Trim$(Str$(labelActive))
Call PropBag.WriteProperty(temp, myLabel(labelActive).Caption, "")
Next
labelActive = tempActive
Call PropBag.WriteProperty("ActiveTab", labelActive, 0)
Call PropBag.WriteProperty("backcolor", TabBackColor, &H8000000F)
Call PropBag.WriteProperty("fontblod", ActiveBlod, False)
Call PropBag.WriteProperty("fonditalic", InactiveItalic, False)
End Sub
Private Sub UserControl_Resize()
Width = UserControl.ScaleWidth
Height = UserControl.ScaleHeight Call Refresh
End Sub
Dim labelActive As Integer
Dim labelAim As IntegerDim labelActHeight As Integer
Dim labelDelableHeight As Integer
Dim labelBlank As Integer
Dim labelHeight As IntegerDim Width As Integer, Height As Integer
Dim TabBackColor As LongDim ActiveBlod As Boolean
Dim InactiveItalic As Boolean
Const lineColor = &HE7DAAE
Const ControlSpace = 10000
Const BlankSpace = 10
Private Type labelData
Caption As String
Width As Integer
Left As Integer
End Type
Dim myLabel() As labelDataPublic Event TabSwitch(ByVal LastActiveTab As Integer)
Public Property Get FontBlod() As Boolean
FontBlod = ActiveBlod
End Property
Public Property Let FontBlod(ByVal vNewValue As Boolean)
ActiveBlod = vNewValue
Call Refresh
End Property
Public Property Get FontItalic() As Boolean
FontItalic = InactiveItalic
End Property
Public Property Let FontItalic(ByVal vNewValue As Boolean)
InactiveItalic = vNewValue
Call Refresh
End Property
Public Property Get BackColor() As OLE_COLOR
BackColor = TabBackColor
End PropertyPublic Property Let BackColor(ByVal vNewValue As OLE_COLOR)
TabBackColor = vNewValue
skin.Line (0, 0)-(3, 0), vNewValue
skin.Line (0, 1)-(2, 1), vNewValue
skin.PSet (0, 2), vNewValue
skin.Line (0, 24)-(3, 24), vNewValue
skin.Line (0, 25)-(2, 25), vNewValue
skin.PSet (0, 26), vNewValue
skin.Line (77, 0)-(80, 0), vNewValue
skin.Line (78, 1)-(80, 1), vNewValue
skin.PSet (79, 2), vNewValue
skin.Line (77, 24)-(80, 24), vNewValue
skin.Line (78, 25)-(80, 25), vNewValue
skin.PSet (79, 26), vNewValue
skin.Refresh
UserControl.BackColor = vNewValue
Call Refresh
End Property
Public Property Get ActiveTab() As Integer
ActiveTab = labelActive
End Property
Public Property Let ActiveTab(ByVal vNewValue As Integer)
Dim LastActive As Integer
If vNewValue < 0 Then vNewValue = 0
If vNewValue >= labelCount Then vNewValue = labelCount - 1
If labelActive <> vNewValue Then
LastActive = labelActive
labelActive = vNewValue
RaiseEvent TabSwitch(LastActive)
Call Refresh
Call ControlRefresh(LastActive)
End If
End Property
Public Property Get Caption() As String
Caption = myLabel(labelActive).Caption
End Property
Public Property Let Caption(ByVal vNewValue As String)
Label1.Caption = vNewValue
With myLabel(labelActive)
.Caption = vNewValue
.Width = Label1.Width + BlankSpace * 2
If .Width < 80 Then .Width = 80
.Left = (.Width - Label1.Width) / 2
End With
Call Refresh
End Property
Public Property Get TabCount() As Integer
TabCount = labelCount
End Property
Public Property Let TabCount(ByVal vNewValue As Integer)
Dim i As Integer, LastActive As Integer
If labelCount = vNewValue Then Exit Property
ReDim Preserve myLabel(vNewValue - 1)
For i = labelCount To vNewValue - 1
myLabel(i).Width = 80
Next
labelCount = vNewValue
LastActive = labelActive
If labelActive > labelCount - 1 Then
labelActive = labelCount - 1
RaiseEvent TabSwitch(LastActive)
Call ControlRefresh(LastActive)
End If
Call Refresh
End PropertyPrivate Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'X = X \ 15
'Y = Y \ 15
Dim i As Integer, Left As Integer, LastActive As Integer
Left = 1
For i = 0 To labelCount - 1
Left = Left + labelBlank
If labelActive <> i And X >= Left And X <= Left + myLabel(i).Width - 1 And Y >= 9 And Y <= labelHeight + 1 Then
LastActive = labelActive
labelActive = i
RaiseEvent TabSwitch(LastActive)
Call Refresh
Call ControlRefresh(LastActive)
Exit For
End If
Left = Left + myLabel(i).Width
Next
End Sub
Private Sub ControlRefresh(LastActive As Integer)
Dim Ctl As Control, MoveVal As Single
If LastActive = labelActive Then Exit Sub
MoveVal = CSng(labelActive - LastActive) * ControlSpace
For Each Ctl In UserControl.ContainedControls
Ctl.Left = Ctl.Left + MoveVal
Next Ctl
End Sub
Public Sub Refresh()
Dim Left As Integer
Left = 1
UserControl.Cls
Line (0, labelHeight + 1)-(Width - 1, Height - 1), &HFFFFFF, BF
For i = 0 To labelCount - 1
Line (Left, labelHeight + 1)-(Left + labelBlank, labelHeight + 1), lineColor
Left = Left + labelBlank
If labelActive = i Then '活动页
UserControl.PaintPicture skin.Image, Left, labelHeight - labelActHeight + 1, myLabel(i).Width, 5, 0, 24, 80, 5
UserControl.PaintPicture skin.Image, Left, labelHeight - labelActHeight + 6, myLabel(i).Width, labelActHeight - 5, 0, 29, 80, 24
Line (Left, 6)-(Left, labelHeight + 2), lineColor
Line (Left + myLabel(i).Width - 1, 6)-(Left + myLabel(i).Width - 1, labelHeight + 2), lineColor
Line (Left + 1, labelHeight + 1)-(Left + myLabel(i).Width - 1, labelHeight + 1), &HFFFFFF
UserControl.CurrentX = Left + myLabel(i).Left
UserControl.CurrentY = 12
UserControl.FontBold = FontBold
UserControl.FontItalic = False
UserControl.Print myLabel(i).Caption
Else
UserControl.PaintPicture skin.Image, Left, labelHeight - labelDelableHeight + 1, myLabel(1).Width, 6, 0, 0, 80, 6
UserControl.PaintPicture skin.Image, Left, labelHeight - labelDelableHeight + 7, myLabel(i).Width, labelDelableHeight - 6, 0, 6, 80, 18
Line (Left, 9)-(Left, labelHeight + 1), lineColor
Line -(Left + myLabel(i).Width - 1, labelHeight + 1), lineColor
Line -(Left + myLabel(i).Width - 1, 9), lineColor
UserControl.CurrentX = Left + myLabel(i).Left
UserControl.CurrentY = 13
UserControl.FontBold = False
UserControl.FontItalic = FontItalic
UserControl.Print myLabel(i).Caption
End If
Left = Left + myLabel(i).Width
Next
Line (Left, labelHeight + 1)-(Width - 1, labelHeight + 1), lineColor
Line -(Width - 1, Height - 1), lineColor
Line -(0, Height - 1), lineColor
Line -(0, labelHeight), lineColor
UserControl.Refresh
End Sub
Private Sub UserControl_Initialize()
labelCount = 3
ReDim myLabel(labelCount - 1)
Dim i As Integer
labelActive = 0
labelAim = -1
For i = 0 To labelCount - 1
myLabel(i).Width = 80
Next
TabBackColor = &HFFFFFF
labelActHeight = 29
labelDelableHeight = 24
labelHeight = 29
labelBlank = 4
End SubPrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)
Dim temp As String
TabCount = PropBag.ReadProperty("tabcount", 3)
ReDim Preserve myLabel(TabCount - 1)
For labelActive = 0 To labelCount - 1
temp = "caption" & Trim$(Str$(labelActive))
Caption = PropBag.ReadProperty(temp, "")
Next
ActiveTab = PropBag.ReadProperty("ActiveTab", 0)
BackColor = PropBag.ReadProperty("backcolor", &H8000000F)
FontBlod = PropBag.ReadProperty("fontblod", False)
FontItalic = PropBag.ReadProperty("fontitalic", False)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Dim temp As String, tempActive As Integer
tempActive = labelActive
Call PropBag.WriteProperty("tabcount", labelCount, 3)
For labelActive = 0 To labelCount - 1
temp = "caption" & Trim$(Str$(labelActive))
Call PropBag.WriteProperty(temp, myLabel(labelActive).Caption, "")
Next
labelActive = tempActive
Call PropBag.WriteProperty("ActiveTab", labelActive, 0)
Call PropBag.WriteProperty("backcolor", TabBackColor, &H8000000F)
Call PropBag.WriteProperty("fontblod", ActiveBlod, False)
Call PropBag.WriteProperty("fonditalic", InactiveItalic, False)
End Sub
Private Sub UserControl_Resize()
Width = UserControl.ScaleWidth
Height = UserControl.ScaleHeight Call Refresh
End Sub
tSettingUp = True
txtCaption.Text = cmbCaptions.Text
txtCaption.SelStart = 0
txtCaption.SelLength = Len(txtCaption.Text)
tSettingUp = False
End SubPrivate Sub cmd_Click(Index As Integer)
Dim t1 As Long, tmp$
With cmbCaptions
Select Case Index
Case 0 'Down
If .ListIndex < .ListCount - 1 Then
tmp = .List(.ListIndex)
.List(.ListIndex) = .List(.ListIndex + 1)
.List(.ListIndex + 1) = tmp
.ListIndex = .ListIndex + 1
Changed = True
End If
Case 1 'Up
If .ListIndex > 0 Then
tmp = .List(.ListIndex)
.List(.ListIndex) = .List(.ListIndex - 1)
.List(.ListIndex - 1) = tmp
.ListIndex = .ListIndex - 1
Changed = True
End If
Case 2 'Add
.AddItem "", .ListIndex + 1
.ListIndex = .ListIndex + 1
Changed = True
Case 3 'Delete
If .ListCount > 1 Then
t1 = .ListIndex
.RemoveItem .ListIndex
.ListIndex = IIf(t1 >= .ListCount, .ListCount - 1, t1)
cmbCaptions_Click
Changed = True
End If
End Select
End With
End SubPrivate Sub txtCaption_Change()
If Not tSettingUp Then
cmbCaptions.List(cmbCaptions.ListIndex) = txtCaption.Text
Changed = True
End If
End Sub
Private Sub PropertyPage_ApplyChanges()
Dim t1 As Integer
With SelectedControls(0)
.TabCount = cmbCaptions.ListCount
For t1 = 1 To .TabCount
.Caption(t1) = cmbCaptions.List(t1 - 1)
Next t1
End With
End SubPrivate Sub PropertyPage_SelectionChanged()
Dim t1 As Integer
tSettingUp = True
With SelectedControls(0)
cmbCaptions.Clear
For t1 = 1 To .TabCount
cmbCaptions.AddItem .Caption(t1)
Next t1
cmbCaptions.ListIndex = 0
cmbCaptions_Click
End With
tSettingUp = False
Refresh
End Sub
cmbCaptions.AddItem .Caption(t1)
这里
你好,
错误是没有了。但是不是数组的话就不能设置属性了。
我把工程上传了。麻烦高手再帮助下,谢谢了。
工程http://download.csdn.net/source/3292094