Results 1 to 28 of 28

Thread: [RESOLVED] [VB6]about timers in UC

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Resolved [RESOLVED] [VB6]about timers in UC

    i'm trying build a game with my Sprite... these game has 2 timers, but sprite control has more 3 timers....
    when i use my sprite control, using the Top property, it give me an error: "the object doesn't support these property or method" but when i stop 1 timer(in my object, but the problem is that i need it) these message don't appear.... can anyone advice-me?
    thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [VB6]about timers in UC

    Can you show us the line(s) of code that is generating the error.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    in game is the 2nd "if":
    Code:
    Private Sub sprPlayer_KeyDown(KeyCode As Integer, Shift As Integer)
        If (KeyCode = vbKeyP Or KeyCode = vbKeyEscape) Then
            frmPausa.Show
        End If
        If KeyCode = vbKeyUp Then
            sprPlayer.Top = sprPlayer.Top - 10
        End If
    End Sub
    in my UC is in timer, because when i desactive the timer the problem got out:
    Code:
    Private Sub tmrNewEvents_Timer()
        Dim I As Integer
        Dim Name As String
        Dim ctlTemp As Control
        Dim L1 As Long
        Dim L2 As Long
        Dim T1 As Long
        Dim T2 As Long
        Dim H1 As Long
        Dim H2 As Long
        Dim W1 As Long
        Dim W2 As Long
        Dim Direction As Direction
        On Error Resume Next
        
        If (blnActivateMoveNotMoveEvents = False And blnJoystickActivate = False) Then tmrNewEvents.Enabled = False
        If blnActivateMoveNotMoveEvents = True Then
            If (lngOldPosX < Extender.Left And lngOldPosY < Extender.Top) Then
                DirDirection = DirectionLeftUp
            ElseIf (lngOldPosX < Extender.Left And lngOldPosY > Extender.Top) Then
                DirDirection = DirectionLeftDown
            ElseIf (lngOldPosX > Extender.Left And lngOldPosY < Extender.Top) Then
                DirDirection = DirectionRightUp
            ElseIf (lngOldPosX > Extender.Left And lngOldPosY > Extender.Top) Then
                DirDirection = DirectionRightDown
            ElseIf (lngOldPosX < Extender.Left) Then
                DirDirection = DirectionLeft
            ElseIf (lngOldPosX > Extender.Left) Then
                DirDirection = DirectionRight
            ElseIf (lngOldPosY < Extender.Top) Then
                DirDirection = DirectionUp
            ElseIf (lngOldPosX > Extender.Top) Then
                DirDirection = DirectionLeftDown
            End If
            If Extender.Left <> lngOldPosX Or Extender.Top <> lngOldPosY Then
                lngOldPosX = Extender.Left
                lngOldPosY = Extender.Top
                RaiseEvent Move(lngOldPosX, lngOldPosY, DirDirection)
                DoEvents
                Name = Extender.Name
                If Col.Activate = True Then
                    L1 = Extender.Left + Col.Left
                    T1 = Extender.Top + Col.Top
                    W1 = Col.Width
                    H1 = Col.Height
                Else
                    L1 = lngOldPosX
                    T1 = lngOldPosY
                    W1 = Extender.Width
                    H1 = Extender.Height
                End If
                For I = 0 To Extender.Container.Controls.Count - 1
                    If Extender.Container.Controls(I).Name <> Name Then
                        If TypeName(Extender.Container.Controls(I)) = "Sprite" Then
                            If Extender.Container.Controls(I).LimColActivate = True Then
                                L2 = Extender.Container.Controls(I).Left + Extender.Container.Controls(I).LimColLeft
                                T2 = Extender.Container.Controls(I).Top + Extender.Container.Controls(I).LimColTop
                                W2 = Extender.Container.Controls(I).LimColWidth
                                H2 = Extender.Container.Controls(I).LimColHeight
                            Else
                                L2 = Extender.Container.Controls(I).Left
                                T2 = Extender.Container.Controls(I).Top
                                W2 = Extender.Container.Controls(I).Width
                                H2 = Extender.Container.Controls(I).Height
                            End If
                            If CollisionPrecise(L1, T1, W1, H1, L2, T2, W2, H2) = True Then
                                RaiseEvent Collision(Extender.Container.Controls(I).Name, IndexControlArray(Extender.Container.Controls(I)), DirDirection)
                                Exit For
                                DoEvents
                            End If
                        Else
                            L2 = Extender.Container.Controls(I).Left
                            T2 = Extender.Container.Controls(I).Top
                            W2 = Extender.Container.Controls(I).Width
                            H2 = Extender.Container.Controls(I).Height
                            If CollisionPrecise(L1, T1, W1, H1, L2, T2, W2, H2) = True Then
                                RaiseEvent Collision(Extender.Container.Controls(I).Name, IndexControlArray(Extender.Container.Controls(I)), DirDirection)
                                Exit For
                                DoEvents
                            End If
                        End If
                    End If
                Next I
            Else
                RaiseEvent NotMove(lngOldPosX, lngOldPosY, DirDirection)
                DoEvents
            End If
        End If
        If (blnJoystickActivate = True And StartJoystick(0) = True) Then
            Call PollJoystick
            If (MYJOYEX.dwXpos = 0 And MYJOYEX.dwYpos = 0) Then
                Direction = DirectionLeftUp
            ElseIf (MYJOYEX.dwXpos = 0 And MYJOYEX.dwYpos = 65535) Then
                Direction = DirectionLeftDown
            ElseIf (MYJOYEX.dwXpos = 65535 And MYJOYEX.dwYpos = 0) Then
                Direction = DirectionRightUp
            ElseIf (MYJOYEX.dwXpos = 65535 And MYJOYEX.dwYpos = 65535) Then
                Direction = DirectionRightDown
            ElseIf (MYJOYEX.dwXpos = 0) Then
                Direction = DirectionLeft
            ElseIf (MYJOYEX.dwXpos = 65535) Then
                Direction = DirectionRight
            ElseIf (MYJOYEX.dwYpos = 0) Then
                Direction = DirectionUp
            ElseIf (MYJOYEX.dwYpos = 65535) Then
                Direction = DirectionDown
            Else
                Direction = DirectionNone
            End If
            RaiseEvent Joystick(JoyNum, Direction, lngButton)
            DoEvents
        End If
    End Sub
    but in my form teste(where i test these control), i don't recive any error...
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [VB6]about timers in UC

    Is sprPlayer a control in your uc? Or is sprPlayer a dynamic control that you change during runtime? When you get the error, can you debug.print these and show us the result.

    Debug.Print (sprPlayer Is Nothing)
    Debug.Print TypeName(sprPlayer)
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    Quote Originally Posted by LaVolpe
    Is sprPlayer a control in your uc? Or is sprPlayer a dynamic control that you change during runtime? When you get the error, can you debug.print these and show us the result.

    Debug.Print (sprPlayer Is Nothing)
    Debug.Print TypeName(sprPlayer)
    the sprPlayer is an instance of my Sprite control.
    Debug.Print (sprPlayer Is Nothing)=false
    Debug.Print TypeName(sprPlayer)=sprite
    VB6 2D Sprite control

    To live is difficult, but we do it.

  6. #6

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    see you self...
    in Sprite folder is where you must compile the Sprite and put it in CatchDiamonds folder...
    then test the game CatchDiamonds... use the Up key...
    i'm rebuild the entire game, but now just crash
    i'm sorry if i give you much work... thanks
    Last edited by joaquim; May 29th, 2009 at 04:55 AM.
    VB6 2D Sprite control

    To live is difficult, but we do it.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [VB6]about timers in UC

    You might want to update your last posting and include your project also as Zip files. Not everyone uses WinRar.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    (help me on these 1 zip file is 900Kb's... i have winzip 9... how can i zip the file with 500Kb(for example) by parts?
    thanks)
    VB6 2D Sprite control

    To live is difficult, but we do it.

  9. #9
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    Okay, the problem is not with:

    vb Code:
    1. If KeyCode = vbKeyUp Then
    2.         sprPlayer.Top = sprPlayer.Top - 10
    3.     End If

    The problem is with the code right before it that you didn't post above. sprPlayer is a picturebox and .Filename is not a valid property of a picturebox. To change the picture in a picturebox, do this:

    vb Code:
    1. Private Sub sprPlayer_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If KeyCode = vbKeyP Then
    3.         MsgBox "Pause"
    4.     End If
    5.     If KeyCode = vbKeyEscape Then
    6.         End
    7.     End If
    8.     If KeyCode = vbKeyUp Then
    9.         If blnCollisionUp = True Then
    10.             If plPlayer = Male Then
    11.                 'If sprPlayer.FileName <> App.Path & "\Images\Male Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Stoped\Up.gif"
    12.                 sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Stoped\Up.gif")
    13.             Else
    14.                 'If sprPlayer.FileName <> App.Path & "\Images\Female Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Stoped\Up.gif"
    15.                 sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Stoped\Up.gif")
    16.             End If
    17.         Else
    18.             If plPlayer = Male Then
    19.                 'If sprPlayer.FileName <> App.Path & "\Images\Male Player\Movement\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Movement\Up.gif"
    20.                 sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Movement\Up.gif")
    21.             Else
    22.                 'If sprPlayer.FileName <> App.Path & "\Images\Female Player\Movement\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Movement\Up.gif"
    23.                 sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Movement\Up.gif")
    24.             End If
    25.             sprPlayer.Top = sprPlayer.Top - 10
    26.         End If
    27.     End If
    28. End Sub
    29.  
    30. Private Sub Form_Load()
    31.     picGame.Picture = LoadPicture(App.Path & "\Images\Background\Level1.gif")
    32.     plPlayer = Male
    33.     blnCollisionDown = False
    34.     blnCollisionLeft = False
    35.     blnCollisionRight = False
    36.     blnCollisionUp = False
    37.     picGame.Picture = LoadPicture(App.Path & "\Images\Background\Level1.gif")
    38.     If plPlayer = Male Then
    39.         'If sprPlayer.Picture <> App.Path & "\Images\Male Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Stoped\Up.gif"
    40.         sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Stoped\Up.gif")
    41.     Else
    42.         'If sprPlayer.Picture <> App.Path & "\Images\Female Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Stoped\Up.gif"
    43.         sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Stoped\Up.gif")
    44.     End If
    45. End Sub

    To check to see which picture is in the box, you might want to have a variable that is changed every time you load a new picture into the picturebox that will tell you what the last one loaded was.

    If you need example code of this, just let me know.

    Enjoy.

  10. #10

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    Quote Originally Posted by deathfxu
    Okay, the problem is not with:

    vb Code:
    1. If KeyCode = vbKeyUp Then
    2.         sprPlayer.Top = sprPlayer.Top - 10
    3.     End If

    The problem is with the code right before it that you didn't post above. sprPlayer is a picturebox and .Filename is not a valid property of a picturebox. To change the picture in a picturebox, do this:

    vb Code:
    1. Private Sub sprPlayer_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If KeyCode = vbKeyP Then
    3.         MsgBox "Pause"
    4.     End If
    5.     If KeyCode = vbKeyEscape Then
    6.         End
    7.     End If
    8.     If KeyCode = vbKeyUp Then
    9.         If blnCollisionUp = True Then
    10.             If plPlayer = Male Then
    11.                 'If sprPlayer.FileName <> App.Path & "\Images\Male Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Stoped\Up.gif"
    12.                 sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Stoped\Up.gif")
    13.             Else
    14.                 'If sprPlayer.FileName <> App.Path & "\Images\Female Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Stoped\Up.gif"
    15.                 sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Stoped\Up.gif")
    16.             End If
    17.         Else
    18.             If plPlayer = Male Then
    19.                 'If sprPlayer.FileName <> App.Path & "\Images\Male Player\Movement\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Movement\Up.gif"
    20.                 sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Movement\Up.gif")
    21.             Else
    22.                 'If sprPlayer.FileName <> App.Path & "\Images\Female Player\Movement\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Movement\Up.gif"
    23.                 sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Movement\Up.gif")
    24.             End If
    25.             sprPlayer.Top = sprPlayer.Top - 10
    26.         End If
    27.     End If
    28. End Sub
    29.  
    30. Private Sub Form_Load()
    31.     picGame.Picture = LoadPicture(App.Path & "\Images\Background\Level1.gif")
    32.     plPlayer = Male
    33.     blnCollisionDown = False
    34.     blnCollisionLeft = False
    35.     blnCollisionRight = False
    36.     blnCollisionUp = False
    37.     picGame.Picture = LoadPicture(App.Path & "\Images\Background\Level1.gif")
    38.     If plPlayer = Male Then
    39.         'If sprPlayer.Picture <> App.Path & "\Images\Male Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Stoped\Up.gif"
    40.         sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Stoped\Up.gif")
    41.     Else
    42.         'If sprPlayer.Picture <> App.Path & "\Images\Female Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Stoped\Up.gif"
    43.         sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Stoped\Up.gif")
    44.     End If
    45. End Sub

    To check to see which picture is in the box, you might want to have a variable that is changed every time you load a new picture into the picturebox that will tell you what the last one loaded was.

    If you need example code of this, just let me know.

    Enjoy.
    i'm sorry but isn't a picturebox, it's my sprite control you must compile it(is in *.rar files)... i'm sorry about that....
    please compile my sprite control then put in game folder, Catch Dimonds, then run it again and test it... i'm sorry and thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

  11. #11
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    lol. When I opened the project there was a picturebox of the same name in the middle of the form. Sorry man, i'll rerun it.

  12. #12

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    "lol. When I opened the project there was a picturebox of the same name in the middle of the form."
    that's normal, after the error... after you compile my sprite and put it in folder game and run the project and click up key, you will see the error.
    try test it putting the MoveNotMove and JoystickActivate true and false(you will see that the error is out)... but i need these properties true.

    "Sorry man, i'll rerun it"
    that's ok... honestly, thanks for you trying help me
    VB6 2D Sprite control

    To live is difficult, but we do it.

  13. #13
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    I kept getting an error in the Sprite project when you were trying to set MaskColor to "Null". I changed it to "vbNull", recompiled, ran CatchDiamonds, and when I hit the up key Visual Basic froze, lol.

    So this might take a few mins. =P

    Edit: "Hard Froze". Like [ctrl]+[pausebreak] didn't even work.

  14. #14

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    Quote Originally Posted by deathfxu
    I kept getting an error in the Sprite project when you were trying to set MaskColor to "Null". I changed it to "vbNull", recompiled, ran CatchDiamonds, and when I hit the up key Visual Basic froze, lol.

    So this might take a few mins. =P

    Edit: "Hard Froze". Like [ctrl]+[pausebreak] didn't even work.
    yes... i test(only know) that error... before it don't give me the error
    i'm confuse with these
    thanks for help me
    VB6 2D Sprite control

    To live is difficult, but we do it.

  15. #15
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    Okay, this program is so massive it's taking me a while to trace it through. Do you know why Sprite.ocx is calling the ShowImage sub like 20 times right when it starts up?

  16. #16

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    Quote Originally Posted by deathfxu
    Okay, this program is so massive it's taking me a while to trace it through. Do you know why Sprite.ocx is calling the ShowImage sub like 20 times right when it starts up?
    20 times!?!
    i think not.... only in some properties...
    VB6 2D Sprite control

    To live is difficult, but we do it.

  17. #17
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    Never mind. I just realized that every graphics-related Property Let statement recalls it for each time when you are initializing all the values.

  18. #18
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    In the CatchDiamonds project, the sprPlayer_KeyDown is only getting called the first time you press a key, but neither project is getting stuck in an infinite loop.

    Which means something may be disabling the event trigger for it.

    Still looking.

  19. #19
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    FINALLY!!!

    Almost 2 hours later.

    First change:

    vb Code:
    1. Public Property Let FileName(New_FileName As String)
    2.     Dim I As Integer
    3.     strFileName = New_FileName
    4.     tmrAnimation.Enabled = False
    5.     If (Dir(strFileName) = "" Or ValidFile(UCase(strFileName)) = False) Then
    6.         UserControl.Picture = Nothing
    7.         UserControl.MaskPicture = Nothing
    8.         UserControl.MaskColor = Null 'Change this to "vbNull"

    Then, the usercontrol Sprite.ocx is losing focus after the first keypress. Into the form and all objects on it in _KeyDown I added:

    vb Code:
    1. Call sprPlayer_KeyDown(KeyCode, Shift)

    And it worked. If you can't duplicate this, lemme know.
    Last edited by deathfxu; Mar 13th, 2009 at 07:57 PM.

  20. #20
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    Also, to help debugging, I removed your test project "teste", and added frmLevel1 to the project and set it as the startup object. It allowed me to breakpoint both projects at once.

    I can walk you through how to do that also if you don't understand what I mean.

  21. #21

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    Quote Originally Posted by deathfxu
    FINALLY!!!

    Almost 2 hours later.

    First change:

    vb Code:
    1. Public Property Let FileName(New_FileName As String)
    2.     Dim I As Integer
    3.     strFileName = New_FileName
    4.     tmrAnimation.Enabled = False
    5.     If (Dir(strFileName) = "" Or ValidFile(UCase(strFileName)) = False) Then
    6.         UserControl.Picture = Nothing
    7.         UserControl.MaskPicture = Nothing
    8.         UserControl.MaskColor = Null 'Change this to "vbNull"

    Then, the usercontrol Sprite.ocx is losing focus after the first keypress. Into the form and all objects on it in _KeyDown I added:

    vb Code:
    1. Call sprPlayer_KeyDown(KeyCode, Shift)

    And it worked. If you can't duplicate this, lemme know.
    i have 1 question: if the sprPlayer TabIndex property is 0, why it loses the focus?
    thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

  22. #22

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    Quote Originally Posted by deathfxu
    Also, to help debugging, I removed your test project "teste", and added frmLevel1 to the project and set it as the startup object. It allowed me to breakpoint both projects at once.

    I can walk you through how to do that also if you don't understand what I mean.
    if you have the frmLevel1 in Sprite project, how can you compile the OCX file?
    thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

  23. #23

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    i continue with same problem
    i'm trying without sucess
    VB6 2D Sprite control

    To live is difficult, but we do it.

  24. #24

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    i found where is the error, but i don't understand it
    Code:
    MsgBox "oi"
                If Extender.Container.Controls.Count > 1 Then
                For I = 0 To Extender.Container.Controls.Count - 1
                    If Extender.Container.Controls(I).Name <> Name Then
                        If TypeName(Extender.Container.Controls(I)) = "Sprite" Then
                            If Extender.Container.Controls(I).LimColActivate = True Then
                                L2 = Extender.Container.Controls(I).Left + Extender.Container.Controls(I).LimColLeft
                                T2 = Extender.Container.Controls(I).Top + Extender.Container.Controls(I).LimColTop
                                W2 = Extender.Container.Controls(I).LimColWidth
                                H2 = Extender.Container.Controls(I).LimColHeight
                            Else
                                L2 = Extender.Container.Controls(I).Left
                                T2 = Extender.Container.Controls(I).Top
                                W2 = Extender.Container.Controls(I).Width
                                H2 = Extender.Container.Controls(I).Height
                            End If
                            If CollisionPrecise(L1, T1, W1, H1, L2, T2, W2, H2) = True Then
                                RaiseEvent Collision(Extender.Container.Controls(I).Name, IndexControlArray(Extender.Container.Controls(I)), DirDirection)
                                Exit For
                                DoEvents
                            End If
                        Else
                            L2 = Extender.Container.Controls(I).Left
                            T2 = Extender.Container.Controls(I).Top
                            W2 = Extender.Container.Controls(I).Width
                            H2 = Extender.Container.Controls(I).Height
                            If CollisionPrecise(L1, T1, W1, H1, L2, T2, W2, H2) = True Then
                                RaiseEvent Collision(Extender.Container.Controls(I).Name, IndexControlArray(Extender.Container.Controls(I)), DirDirection)
                                Exit For
                                DoEvents
                            End If
                        End If
                    End If
                Next I
                End If
            Else
                RaiseEvent NotMove(lngOldPosX, lngOldPosY, DirDirection)
                DoEvents
            End If
        End If
    the messagebox is showed, but then is give me an error(i use the messagebox for catch the error)
    if i put the messagebox in the If statement, i will recive the error...
    what isn't right with these line:
    Code:
    Extender.Container.Controls.Count > 1
    ????
    error message: "these object doesn't support this property or method"
    thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

  25. #25
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    Quote Originally Posted by joaquim
    i have 1 question: if the sprPlayer TabIndex property is 0, why it loses the focus?
    thanks
    No. TabIndex changes the order that controls get focus when you press the [tab] key.

  26. #26
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    Quote Originally Posted by joaquim
    if you have the frmLevel1 in Sprite project, how can you compile the OCX file?
    thanks
    I wasn't compiling it, I was just running it straight out of the project.

  27. #27
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: [VB6]about timers in UC

    Quote Originally Posted by joaquim
    i found where is the error, but i don't understand it
    the messagebox is showed, but then is give me an error(i use the messagebox for catch the error)
    if i put the messagebox in the If statement, i will recive the error...
    what isn't right with these line:
    Code:
    Extender.Container.Controls.Count > 1
    ????
    error message: "these object doesn't support this property or method"
    thanks
    I didn't get any error here. I left the project on my computer in case you had any problems, and I just went back in and ran it with no problems. I'm tempted to just send the files back to you.

    Have you been making other changes?

  28. #28

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6]about timers in UC

    "I didn't get any error here. I left the project on my computer in case you had any problems, and I just went back in and ran it with no problems. I'm tempted to just send the files back to you."
    i belive you don't get the error, but try compile it and try use it in other project... use any key for move it... here you will see it.

    "Have you been making other changes?"
    yes...
    Code:
    UserControl.Parent.Controls.Count
    isn't the same but works fine for it is.... but i'm continue testing
    VB6 2D Sprite control

    To live is difficult, but we do it.

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