Destroying objects that was builded in project-mode
i'm trying build a method in my Sprite control for destroy it self, but until now without sucess
(in these case) the control is created in project-mode and deleted in run-mode...
any sugestions?
thanks
Re: Destroying objects that was builded in project-mode
Originally Posted by dglienna
On Error Resume Next is hiding your problem. Comment that line out, and try it again.
You still need to supply more code. How do you get the values? How do you create them?
Why don't you create a file of icons, and load them?
ok... i put here my group project, now you can see everything.
in UC you have the Destroyed procedure in Declaration section.
see and tell me what you think.... the FileName property is for you change the image(animateg cursors and gifs can be showed too).
thanks
Re: Destroying objects that was builded in project-mode
Well, trying to exit with the Close 'X' crashes the IDE. Clicking on STOP in the IDE works correctly. I would use XML files to access the data in the property bag that is named.
Re: Destroying objects that was builded in project-mode
Originally Posted by dglienna
Well, trying to exit with the Close 'X' crashes the IDE. Clicking on STOP in the IDE works correctly. I would use XML files to access the data in the property bag that is named.
yes i know about that error, but why?
for me it's strange
thanks for help me
did you want my msn(messenger) for more help(honestly i need more help in more things, in my sprite)?
(i found something interesting: http://books.google.pt/books?id=kVqB...um=8#PPA371,M1 )thanks
Re: Destroying objects that was builded in project-mode
Because your app is sub-classing memory locations to fool the IDE into thinking something is different. The caution is that you can toast Windows, not only the IDE when you're writing memory that goes awry.
Re: Destroying objects that was builded in project-mode
The exception in your program is generated when you try to set the UserControl.Height/Width in ShowImage after the window is destroyed. This will trigger UserControl_Resize which in turn calls ShowImage again, which will trigger the UserControl_Resize again and so on. It's a kind of stack overflow although the error says something else.
To prevent this error, you can add validation in your UserControl_Resize. If the UserControl.hWnd is valid (not 0), then perform the codes, otherwise, do nothing.
Code:
Private Sub UserControl_Resize()
If UserControl.hWnd = 0 Then
Debug.Print "UserControl_Resize ignored (HWND = 0)"
Else
On Error Resume Next
If blnAutoSize = False Then
picGraphicsEffects.Width = UserControl.ScaleWidth
picGraphicsEffects.Height = UserControl.ScaleHeight
End If
Call ShowImage
If (UserControl.Width <> lngOldWidth And UserControl.Height <> lngOldHeight) Then
ResizeTyp = ResizeVerticalHorizontal
ElseIf UserControl.Width <> lngOldWidth Then
ResizeTyp = ResizeHorizontal
ElseIf UserControl.Height <> lngOldHeight Then
ResizeTyp = ResizeVertical
End If
lngOldWidth = UserControl.Width
lngOldHeight = UserControl.Height
If strFileName = Empty Then Call SubTransparent
RaiseEvent Resize(UserControl.Width, UserControl.Height, ResizeTyp)
End If
End Sub
You can also check the hWnd even earlier than calling ShowImage if you want (e.g. even before calling Destroyed)
Hope it will help you
Last edited by rxbagain; April 21st, 2009 at 09:32 PM.
Re: Destroying objects that was builded in project-mode
The memory location for UserControl.Height/Width might have been valid at one point, but not after the pointer was no longer pointing to a vaild width.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.