[VB6] - activex compiled problems:(
ok. my project can create the ocx file without a problem. then i try use it in other project, in project works(before be executed) but in execute mode give me some errors:
run-time error '13'
type mismatch
run-time '440'
automation error
(in next execute or back in project)
run-time '429'
activex component can't create object
can anyone tell me why these bugs and why i only see them after compiled?
Re: [VB6] - activex compiled problems:(
User logging and/or error trapping in the following events to determine where the problem may be.
UserControl_Initialize
UserControl_InitProperties
UserControl_ReadProperties
UserControl_Resize
UserControl_Terminate
UserControl_Paint (if you use that sub)
Once you know where the error is coming from, and you know what object it was that could not be created, which line is giving you type mistmatch, then give us more details if you haven't figured out how to fix the error(s)
Re: [VB6] - activex compiled problems:(
Quote:
Originally Posted by
LaVolpe
User logging and/or error trapping in the following events to determine where the problem may be.
UserControl_Initialize
UserControl_InitProperties
UserControl_ReadProperties
UserControl_Resize
UserControl_Terminate
UserControl_Paint (if you use that sub)
Once you know where the error is coming from, and you know what object it was that could not be created, which line is giving you type mistmatch, then give us more details if you haven't figured out how to fix the error(s)
thanks to you i block the error using:
Code:
On Error Resume Next
in both events that you tell me. maybe tomorrow i will try catch the event that causes the error... thanks for everything my
Re: [VB6] - activex compiled problems:(
let me ask anotherthing: i block the errors in vb6, but i see them in VC++ 6. if i catch and block the error line, my control will be compatible with VC++ 6?
Re: [VB6] - activex compiled problems:(
finally i found the sub(event) problem:
Code:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
'On Error Resume Next
FileName = PropBag.ReadProperty("FileName", "")
MouseIcon = PropBag.ReadProperty("MouseIcon", "")
ChangeImageTime = PropBag.ReadProperty("ChangeImageTime", 100)
HoverTime = PropBag.ReadProperty("HoverTime", 100)
Col.Height = PropBag.ReadProperty("LimColHeight", 0)
Col.Left = PropBag.ReadProperty("LimColLeft", 0)
Col.Top = PropBag.ReadProperty("LimColTop", 0)
Col.Width = PropBag.ReadProperty("LimColWidth", 0)
Strip.Height = PropBag.ReadProperty("StripsHeight", 0)
Strip.ImagesColumn = PropBag.ReadProperty("StripsImagesColumn", 0)
Strip.ImagesLine = PropBag.ReadProperty("StripsImagesLine", 0)
Strip.Left = PropBag.ReadProperty("StripsLeft", 0)
Strip.SeparationHorizontal = PropBag.ReadProperty("StripsSeparationHorizontal", 0)
Strip.SeparationVertical = PropBag.ReadProperty("StripsSeparationVertical", 0)
Strip.Top = PropBag.ReadProperty("StripsTop", 0)
Strip.Width = PropBag.ReadProperty("StripsWidth", 0)
StripsActivate = PropBag.ReadProperty("StripsActivate", False)
ActivateMoveNotMoveEvents = PropBag.ReadProperty("ActivateMoveNotMoveEvents", True)
ActivateJoystick = PropBag.ReadProperty("ActivateJoystick", True)
Transparent = PropBag.ReadProperty("Transparent", TransparentAutomatic)
TransparentColor = PropBag.ReadProperty("TransparentColor", lngTransparentColor)
Animation = PropBag.ReadProperty("Animation", AnimationStopped)
Mirror = PropBag.ReadProperty("Mirror", None)
Stretch = PropBag.ReadProperty("Stretch", False)
Opacy = PropBag.ReadProperty("Opacy", 0)
AutoSize = PropBag.ReadProperty("AutoSize", True)
Rotate = PropBag.ReadProperty("Rotate", 0)
BlackandWhite = PropBag.ReadProperty("BlackAndWhite", False)
AutoRedraw = PropBag.ReadProperty("AutoRedraw", True)
Tiles = PropBag.ReadProperty("Tiles", False)
OldColor = PropBag.ReadProperty("OldColor", vbBlack)
NewColor = PropBag.ReadProperty("NewColor", vbBlack)
ActualSubImage = PropBag.ReadProperty("ActualSubImage", 0)
ShadowColor = PropBag.ReadProperty("ShadowColor", vbBlack)
ShadowX = PropBag.ReadProperty("ShadowX", 0)
ShadowY = PropBag.ReadProperty("ShadowY", 0)
Backcolor = PropBag.ReadProperty("BackColor", vbBlack)
strObjectNames() = Split(PropBag.ReadProperty("ObjectSelected", ""), Chr$(8))
ColisionObjectList = PropBag.ReadProperty("ColisionObjectList", ObjectListColisionAutomatic)
ColisionDetectType = PropBag.ReadProperty("ColisionDetectType", ColisionDetectionAutomatic)
UserControl.BorderStyle = PropBag.ReadProperty("BorderStyle", 0)
UserControl.Appearance = PropBag.ReadProperty("Appearance", 1)
FlashingTime = PropBag.ReadProperty("FlashingTime", 0)
BorderSelectionColor = PropBag.ReadProperty("BorderSelectionColor", vbBack)
BorderSelectionWidth = PropBag.ReadProperty("BorderSelectionWidth", 0)
End Sub
now i'm trying catch the right problem line
Re: [VB6] - activex compiled problems:(
ok...i still not catching the line problem:( but in VB& works fine....
i'm trying testing these control in VB2008 and in VC++, but i still reciving the sames errors messages and i can't see 2 properties(in property window): FileName and FlashingTime. can anyone advice me?
thanks
Re: [VB6] - activex compiled problems:(
Remember our discussion in another thread about ReadProperties? I strongly suggested do not use the actual Property for the result of the propertybag value.
In other words, I am guessing that FlashingTime is the property, not the value that holds the value. So...
Code:
' don't use
FlashingTime = PropBag.ReadProperty("FlashingTime", 0)
' use... replace m_FlashTime with whatever your real variable name is
m_FlashTime = PropBag.ReadProperty("FlashingTime", 0)
Maybe you should post your FileName and FlashingTime properties so we can have a look
Re: [VB6] - activex compiled problems:(
Code:
Public Property Get FileName() As String
FileName = strFileName
End Property
Public Property Let FileName(New_FileName As String)
Dim i As Integer
If strFileName = New_FileName Then
If lngTotalSubImages > 1 Then
Animation = AnimationPlay
ChangeImageTime = lngChangeImageTime
End If
Exit Property
End If
strFileName = New_FileName
aniAnimation = AnimationStopped
Set UserControl.Picture = Nothing
Set UserControl.MaskPicture = Nothing
UserControl.MaskColor = UserControl.BackColor
PicAnimation(0).Tag = 0
If (Dir(strFileName) = "" Or ValidFile(UCase(strFileName)) = False) Then
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
PicAnimation(0).Tag = 0
If (UCase(strFileName) Like "*.GIF") Then
For i = 1 To PicAnimation.Count - 1
Unload PicAnimation(i)
Next i
Set imgSize.Picture = Nothing
AnimatedGif.Destroy
AnimatedGif.LoadFromFile strFileName
imgSize.Height = AnimatedGif.Height
imgSize.Width = AnimatedGif.Width
PicAnimation(0).Height = imgSize.Height
PicAnimation(0).Width = imgSize.Width
PicAnimation(0).Picture = AnimatedGif.Image
For i = 2 To AnimatedGif.GIFFrames
AnimatedGif.ChangeFrame i
Load PicAnimation(i - 1)
PicAnimation(i - 1).Height = imgSize.Height
PicAnimation(i - 1).Width = imgSize.Width
PicAnimation(i - 1).Picture = AnimatedGif.Image
Next i
PicAnimation(0).Tag = AnimatedGif.AnimationTime
ElseIf (UCase(strFileName) Like "*.ANI") Or (UCase(strFileName) Like "*.CUR") Then
AnimatedGif.Destroy
Call AnimatedCursor(strFileName, PicAnimation)
Set imgSize.Picture = Nothing
Set imgSize.Picture = PicAnimation(0).Image
imgSize.Width = BmpInfo.bmWidth
imgSize.Height = BmpInfo.bmHeight
ElseIf (UCase(strFileName) Like "*.PNG") Or (UCase(strFileName) Like "*.TIF") Or (UCase(strFileName) Like "*.TIFF") Then
Dim Token As Long
Token = InitGDIPlus
PicAnimation(0).Picture = LoadPictureGDIPlus(strFileName, , , lngBackColor)
Set imgSize.Picture = Nothing
Set imgSize.Picture = LoadPictureGDIPlus(strFileName, , , lngBackColor)
FreeGDIPlus Token
Else
Set imgSize.Picture = Nothing
Set imgSize.Picture = LoadPicture(strFileName)
PicAnimation(0).Picture = LoadPicture(strFileName)
End If
If UCase(strFileName) Like "*.ANI" = True Then
lngBackColor = GetPixel(PicAnimation(0).hDC, BmpInfo.bmWidth, BmpInfo.bmHeight)
Else
lngBackColor = GetPixel(PicAnimation(0).hDC, 0, 0)
End If
UserControl.BackColor = lngBackColor
lngBackColor = UserControl.BackColor
lngOldBackColor = UserControl.BackColor
lngChangeImageTime = IFF(PicAnimation(0).Tag > 0, PicAnimation(0).Tag, 500)
lngActualSubImage = IFF(Strip.Activate = True, 1, 0)
lngTotalSubImages = IFF(Strip.Activate = True, PicAnimation.Count - 1, PicAnimation.Count)
If StripsActivate = True Then
Call UpgradeSubimages
Set imgSize.Picture = PicAnimation(lngActualSubImage).Image
End If
Call ShowImage
If lngTotalSubImages > 1 Then
Animation = AnimationPlay
ChangeImageTime = lngChangeImageTime
End If
PropertyChanged "FileName"
End Property
Public Property Get FlashingTime() As Long
FlashingTime = lngFlashingTime
End Property
Public Property Let FlashingTime(newFlashingTime As Long)
lngFlashingTime = newFlashingTime
If lngFlashingTime > 0 And Ambient.UserMode = True Then
tmrFlashing.Enabled = False
tmrFlashing.Interval = lngFlashingTime
tmrFlashing.Enabled = True
tmrFlashing.Precise = True
ShowWindow UserControl.hWnd, 1
Else
tmrFlashing.Precise = False
tmrFlashing.Enabled = False
blnFlashingTime = True
ShowWindow UserControl.hWnd, 5
End If
PropertyChanged "FlashingTime"
End Property
and i belive that i can't see the AutoSize(maybe more properties).... why works 100% in VB6, but not in VB2008?
some errors don't make sence for me(i did that changes, thanks)
Re: [VB6] - activex compiled problems:(
For a test, rem out these lines in FlashingTime
ShowWindow UserControl.hWnd,5 and ShowWindow UserControl.hWnd,1
If that resolved the errors, ok. Otherwise, error may be caused in your Call ShowImage routine.
Two things.
1) Add error trapping to these routines. This way you'll know which one is causing the error.
2) Even when find the routine causing the error, you may not be able to do anything about it. A uc's Ambient properties (i.e. Ambient.UserMode), Extender, Parent properties and maybe even its hDC or hWnd may not be available at time of ReadProperites. The control must be sited for all properties to be avaliable for use. A control is not guaranteed to be sited during ReadProperties.
Once you find the line of code causing the error, you can try to ignore it and see if your uc displays correctly. If not, I think you have some reworking to do. And here's where I'd start
1) Make backup of your project
2) Do not call Properties from ReadProperties !!!
3) Load all your propertybag values into the variables that hold those values
4) Create a simple routine that will start your uc. It will load the file, set timers, load pictureboxes, etc, etc.
5) In UserControl_Show, call that new simple routine. When UserControl_Show is called your uc is guaranteed to be sited.