joaquim
Mar 21st, 2009, 02:12 AM
i have 1 property in my UC:
Public Property Get FileName() As String
FileName = strFileName
End Property
Public Property Let FileName(New_FileName As String)
Dim I As Integer
strFileName = New_FileName
tmrAnimation.Enabled = False
If (Dir(strFileName) = "" Or ValidFile(UCase(strFileName)) = False) Then
UserControl.Picture = Nothing
UserControl.MaskPicture = Nothing
UserControl.MaskColor = vbNull
UserControl.Cls
Strip.Activate = False
StripsActivate = Strip.Activate
lngActualSubImage = 0
lngTotalSubImages = 0
aniAnimation = AnimationStopped
If PicAnimation.Count > 1 Then
For I = 1 To PicAnimation.Count - 1
Unload PicAnimation(I)
If shpSubImage.Count > 1 Then
Unload shpSubImage(I)
End If
Next I
End If
Exit Property
End If
If PicAnimation.Count > 1 Then
For I = 1 To PicAnimation.Count - 1
Unload PicAnimation(I)
If shpSubImage.Count > 1 Then
Unload shpSubImage(I)
End If
Next I
End If
If (UCase(strFileName) Like "*.GIF") Then
If LoadGif(strFileName, PicAnimation) = True Then
If PicAnimation.Count = 1 Then
PicAnimation(0).Picture = LoadPicture(strFileName)
Else
lngChangeImageTime = TimeSpeed
tmrAnimation.Interval = lngChangeImageTime
End If
End If
UserControl.Width = PicAnimation(0).ScaleWidth * Screen.TwipsPerPixelX
UserControl.Height = PicAnimation(0).ScaleHeight * Screen.TwipsPerPixelY
ElseIf (UCase(strFileName) Like "*.ANI") Or (UCase(strFileName) Like "*.CUR") Then
If AnimatedCursor(strFileName, PicAnimation) Then
If PicAnimation.Count > 1 Then tmrAnimation.Interval = lngChangeImageTime
If blnAutoSize = True Then
UserControl.Width = PicAnimation(0).ScaleWidth * Screen.TwipsPerPixelX
UserControl.Height = PicAnimation(0).ScaleHeight * Screen.TwipsPerPixelY
End If
End If
Else
tmrAnimation.Enabled = False
PicAnimation(0).Picture = LoadPicture(strFileName)
End If
lngActualSubImage = 0
lngTotalSubImages = IFF(Strip.Activate = True, PicAnimation.Count - 1, PicAnimation.Count)
If Strip.Activate = True Then
If blnAutoSize = True Then
UserControl.Width = PicAnimation(1).ScaleWidth * Screen.TwipsPerPixelX
UserControl.Height = PicAnimation(1).ScaleHeight * Screen.TwipsPerPixelY
End If
Else
If blnAutoSize = True Then
UserControl.Width = PicAnimation(0).ScaleWidth * Screen.TwipsPerPixelX
UserControl.Height = PicAnimation(0).ScaleHeight * Screen.TwipsPerPixelY
End If
End If
If lngTotalSubImages = 1 Then
If Strip.Activate = True Then
UserControl.Picture = PicAnimation(1).Image
UserControl.BackColor = PicAnimation(1).BackColor
Else
UserControl.Picture = PicAnimation(0).Image
UserControl.BackColor = PicAnimation(0).BackColor
End If
Else
If Strip.Activate = True Then
UserControl.Picture = PicAnimation(1).Image
UserControl.BackColor = PicAnimation(1).BackColor
Else
UserControl.Picture = PicAnimation(0).Image
UserControl.BackColor = PicAnimation(0).BackColor
End If
aniAnimation = AnimationPlay
tmrAnimation.Enabled = True
End If
If UCase(strFileName) Like "*.GIF" And PicAnimation.Count > 1 Then lngActualSubImage = PicAnimation.Count - 1
Col.Height = Extender.Height
Col.Left = Extender.Left
Col.Top = Extender.Top
Col.Width = Extender.Width
StripsActivate = Strip.Activate
DoEvents
Call ShowImage
PropertyChanged "FileName"
End Property
everytime that i call it, in keydown event, is very slow:(.... can stop my UC in more or less 2 seconds.... can anyone advice me?
thanks
Public Property Get FileName() As String
FileName = strFileName
End Property
Public Property Let FileName(New_FileName As String)
Dim I As Integer
strFileName = New_FileName
tmrAnimation.Enabled = False
If (Dir(strFileName) = "" Or ValidFile(UCase(strFileName)) = False) Then
UserControl.Picture = Nothing
UserControl.MaskPicture = Nothing
UserControl.MaskColor = vbNull
UserControl.Cls
Strip.Activate = False
StripsActivate = Strip.Activate
lngActualSubImage = 0
lngTotalSubImages = 0
aniAnimation = AnimationStopped
If PicAnimation.Count > 1 Then
For I = 1 To PicAnimation.Count - 1
Unload PicAnimation(I)
If shpSubImage.Count > 1 Then
Unload shpSubImage(I)
End If
Next I
End If
Exit Property
End If
If PicAnimation.Count > 1 Then
For I = 1 To PicAnimation.Count - 1
Unload PicAnimation(I)
If shpSubImage.Count > 1 Then
Unload shpSubImage(I)
End If
Next I
End If
If (UCase(strFileName) Like "*.GIF") Then
If LoadGif(strFileName, PicAnimation) = True Then
If PicAnimation.Count = 1 Then
PicAnimation(0).Picture = LoadPicture(strFileName)
Else
lngChangeImageTime = TimeSpeed
tmrAnimation.Interval = lngChangeImageTime
End If
End If
UserControl.Width = PicAnimation(0).ScaleWidth * Screen.TwipsPerPixelX
UserControl.Height = PicAnimation(0).ScaleHeight * Screen.TwipsPerPixelY
ElseIf (UCase(strFileName) Like "*.ANI") Or (UCase(strFileName) Like "*.CUR") Then
If AnimatedCursor(strFileName, PicAnimation) Then
If PicAnimation.Count > 1 Then tmrAnimation.Interval = lngChangeImageTime
If blnAutoSize = True Then
UserControl.Width = PicAnimation(0).ScaleWidth * Screen.TwipsPerPixelX
UserControl.Height = PicAnimation(0).ScaleHeight * Screen.TwipsPerPixelY
End If
End If
Else
tmrAnimation.Enabled = False
PicAnimation(0).Picture = LoadPicture(strFileName)
End If
lngActualSubImage = 0
lngTotalSubImages = IFF(Strip.Activate = True, PicAnimation.Count - 1, PicAnimation.Count)
If Strip.Activate = True Then
If blnAutoSize = True Then
UserControl.Width = PicAnimation(1).ScaleWidth * Screen.TwipsPerPixelX
UserControl.Height = PicAnimation(1).ScaleHeight * Screen.TwipsPerPixelY
End If
Else
If blnAutoSize = True Then
UserControl.Width = PicAnimation(0).ScaleWidth * Screen.TwipsPerPixelX
UserControl.Height = PicAnimation(0).ScaleHeight * Screen.TwipsPerPixelY
End If
End If
If lngTotalSubImages = 1 Then
If Strip.Activate = True Then
UserControl.Picture = PicAnimation(1).Image
UserControl.BackColor = PicAnimation(1).BackColor
Else
UserControl.Picture = PicAnimation(0).Image
UserControl.BackColor = PicAnimation(0).BackColor
End If
Else
If Strip.Activate = True Then
UserControl.Picture = PicAnimation(1).Image
UserControl.BackColor = PicAnimation(1).BackColor
Else
UserControl.Picture = PicAnimation(0).Image
UserControl.BackColor = PicAnimation(0).BackColor
End If
aniAnimation = AnimationPlay
tmrAnimation.Enabled = True
End If
If UCase(strFileName) Like "*.GIF" And PicAnimation.Count > 1 Then lngActualSubImage = PicAnimation.Count - 1
Col.Height = Extender.Height
Col.Left = Extender.Left
Col.Top = Extender.Top
Col.Width = Extender.Width
StripsActivate = Strip.Activate
DoEvents
Call ShowImage
PropertyChanged "FileName"
End Property
everytime that i call it, in keydown event, is very slow:(.... can stop my UC in more or less 2 seconds.... can anyone advice me?
thanks