Results 1 to 8 of 8

Thread: [VB6] - multimedia activex control complied error

  1. #1

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

    [VB6] - multimedia activex control complied error

    i build a multimedia timer control. and in groupproject works fine. but compiled gives an error and closes.
    Code:
    Option Explicit
    
    Private lTimerId As Long
    
    Event Timer()
    
    Dim lngInterval As Long
    Dim blnTimer As Boolean
    
    Public Property Get Enabled() As Boolean
        Enabled = blnTimer
    End Property
    
    Public Property Let Enabled(ByVal vNewValue As Boolean)
        If lngInterval < 1 Then Exit Property
        blnTimer = vNewValue
        If Ambient.UserMode = False Then Exit Property
        If blnTimer = True Then
            If lTimerId Then
                'End Current Timer
                If lTimerId Then
                    timeKillEvent lTimerId
                    'KillTimer lHwnd, lTimerId
                    lTimerId = 0
                End If
            End If
            lHwnd = UserControl.hwnd
            lTimerId = timeSetEvent(lngInterval, 0, AddressOf TimerRoutine, 0, TIME_CALLBACK_FUNCTION Or TIME_PERIODIC)
            'lTimerId = SetTimer(lHwnd, 0, lngInterval, AddressOf TimerRoutine)
        ElseIf blnTimer = False Then
            If lTimerId Then
                timeKillEvent lTimerId
                'KillTimer lHwnd, lTimerId
                lTimerId = 0
            End If
        End If
        PropertyChanged "Enabled"
    End Property
    
    Public Property Get Interval() As Long
        Interval = lngInterval
    End Property
    
    Public Property Let Interval(ByVal vNewValue As Long)
        If vNewValue < 0 Then vNewValue = 0
        If Enabled = True Then Exit Property
        lngInterval = vNewValue
        If lngInterval = 0 Then Enabled = False
        PropertyChanged "Interval"
    End Property
    
    Private Sub UserControl_Initialize()
        UserControl.MaskPicture = UserControl.Image
        UserControl.MaskColor = UserControl.Point(0, 0)
    End Sub
    
    Public Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = 1000 Then
            RaiseEvent Timer
        End If
    End Sub
    
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
        Interval = PropBag.ReadProperty("Interval", 0)
        Enabled = PropBag.ReadProperty("Enabled", 0)
    End Sub
    
    Private Sub UserControl_Resize()
        UserControl.Width = 240
        UserControl.Height = 240
    End Sub
    
    Private Sub UserControl_Terminate()
        If lTimerId <> 0 Then
            timeKillEvent lTimerId
            'KillTimer lHwnd, lTimerId
            lTimerId = 0
        End If
    End Sub
    
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
        PropBag.WriteProperty "Interval", Interval, 0
        PropBag.WriteProperty "Enabled", Enabled, 0
    End Sub
    and in a module:
    Code:
    Option Explicit
    
    Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal _
    lpTimerFunc As Long) As Long
    Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    Public Declare Function timeKillEvent Lib "winmm.dll" (ByVal uId As Long) As Long
    Public Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As Long, ByVal uResolution As Long, ByVal lpFunction As Long, ByVal dwUser As Long, ByVal uFlags As Long) As Long
    Public Const TIME_PERIODIC = 1 ' program for continuous periodic event
    Public Const TIME_CALLBACK_FUNCTION = 0
    
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const WM_KEYDOWN = &H100
    Public lHwnd As Long
    
    Public Function TimerRoutine( _
          ByVal wTimerID As Long, ByVal iMsg As Long, _
          ByVal dwUser As Long, ByVal dw1 As Long, ByVal dw2 As Long _
       ) As Long
    
        'Place your code here...
        On Error Resume Next
        SendMessage lHwnd, WM_KEYDOWN, 1000, 0
    End Function
    heres the image error ziped: http://www.megaupload.com/?d=3NMNR5M6.
    please tell me something. these error happens with compiled file
    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] - multimedia activex control complied error

    In a previously related thread, I suggested you not use SendMessage in your callback function. That may be the problem...

    I would suggest removing that line, recompile & test again. If it doesn't crash -- probably SendMessage. I'd also suggest you return to that vbAccelerator link I gave you and read over the section that describes which API calls you can use in that callback function.
    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,966

    Re: [VB6] - multimedia activex control complied error

    Quote Originally Posted by LaVolpe View Post
    In a previously related thread, I suggested you not use SendMessage in your callback function. That may be the problem...

    I would suggest removing that line, recompile & test again. If it doesn't crash -- probably SendMessage. I'd also suggest you return to that vbAccelerator link I gave you and read over the section that describes which API calls you can use in that callback function.
    i try use the PostMessage() api function(like they said that is more stable). but i must build a class\dll or even an activex exe for don't crash. i can build a class, but let me ask you 1 thing: how can i catch the Wnd property automatic(without put a property)?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4

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

    Re: [VB6] - multimedia activex control complied error

    the main objective is for call 1 new event that i'm put it in my control.
    VB6 2D Sprite control

    To live is difficult, but we do it.

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

    Re: [VB6] - multimedia activex control complied error

    If you are going to use a class, simply add a Property Let statement to the class so you can assign an hWnd.

    In that vbAcceleator link I gave you, there was a ready-made high-resolution timer project that could be downloaded.

    P.S. You also must ask yourself whether a high resolution timer is absolutely needed.
    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}

  6. #6

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

    Re: [VB6] - multimedia activex control complied error

    Quote Originally Posted by LaVolpe View Post
    If you are going to use a class, simply add a Property Let statement to the class so you can assign an hWnd.

    In that vbAcceleator link I gave you, there was a ready-made high-resolution timer project that could be downloaded.

    P.S. You also must ask yourself whether a high resolution timer is absolutely needed.
    you have right. but for that i need ask 1 thing: how can i have accuracy of 1 milllisecond(for build timers like tradicional Sonic games)?
    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] - multimedia activex control complied error

    Quote Originally Posted by joaquim View Post
    you have right. but for that i need ask 1 thing: how can i have accuracy of 1 milllisecond(for build timers like tradicional Sonic games)?
    With a VB timer or API timer, you are not going to get that accuracy. Best case with those timers may be about 10 ms. Also standard timers are low priority; there is no guarantee every timer event will be triggered (some may be skipped depending on running code) and other timer events may be delayed for the same reason
    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,966

    Re: [VB6] - multimedia activex control complied error

    Quote Originally Posted by LaVolpe View Post
    With a VB timer or API timer, you are not going to get that accuracy. Best case with those timers may be about 10 ms. Also standard timers are low priority; there is no guarantee every timer event will be triggered (some may be skipped depending on running code) and other timer events may be delayed for the same reason
    but - only for ask- the directx can do it, right?
    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