CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Join Date
    Apr 2009
    Posts
    1,355

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Destroying objects that was builded in project-mode

    Why not create it dynamically, when the app starts. Easier to destroy.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Apr 2009
    Posts
    1,355

    Re: Destroying objects that was builded in project-mode

    Quote Originally Posted by dglienna View Post
    Why not create it dynamically, when the app starts. Easier to destroy.
    my Sprite control objectives:

    1 - quickly building game;

    2 - easy build game.

    is because of these....

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Destroying objects that was builded in project-mode

    Well, without seeing any code, it seems that you want a magic answer, when the solution is to do some legwork now.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Apr 2009
    Posts
    1,355

    Re: Destroying objects that was builded in project-mode

    Quote Originally Posted by dglienna View Post
    Well, without seeing any code, it seems that you want a magic answer, when the solution is to do some legwork now.
    sorry, you have right.
    heres my procedure
    Private Sub Destroyed()
    On Error Resume Next
    RaiseEvent Destroyed(lngOldPosX, lngOldPosY)
    tmrNewEvents.Enabled = False
    tmrAnimation.Enabled = False
    tmrMouseStoped.Enabled = False
    FileName = Empty
    Set UserControl.MaskPicture = Nothing
    Unhook2 UserControl.ParentControls(0).hWnd
    HoverTime = 0
    End Sub
    i have try using the destroywindow() api function and the and releaseDc() api function, ~but without sucess
    i acept advices

  6. #6
    Join Date
    Apr 2009
    Posts
    1,355

    Re: Destroying objects that was builded in project-mode

    i recive o(zero) in messagebox
    Code:
    MsgBox (ReleaseDC(Me.hWnd, UserControl.hdc))
    information in these api function: http://www.ex-designz.net/apidetail.asp?api_id=330
    (i'm portuguese)

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Destroying objects that was builded in project-mode

    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?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    Apr 2009
    Posts
    1,355

    Re: Destroying objects that was builded in project-mode

    Quote Originally Posted by dglienna View Post
    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
    Attached Files Attached Files

  9. #9
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Destroying objects that was builded in project-mode

    I can't help with Vista/64, as I recall. I can try later.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  10. #10
    Join Date
    Apr 2009
    Posts
    1,355

    Re: Destroying objects that was builded in project-mode

    Quote Originally Posted by dglienna View Post
    I can't help with Vista/64, as I recall. I can try later.
    ok.. but anyway, can you give me some advices?
    thanks

  11. #11
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    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.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  12. #12
    Join Date
    Apr 2009
    Posts
    1,355

    Re: Destroying objects that was builded in project-mode

    Quote Originally Posted by dglienna View Post
    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

  13. #13
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    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.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  14. #14
    Join Date
    Apr 2003
    Posts
    1,755

    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.

  15. #15
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    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.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured