Callback issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jake

    Callback issue

    This is a great set of code for TAPI which does everything; however, I am
    having the worst time trying to figure out why the form is being
    reinitialized from the timerhandler instead of just calling
    GetLineMessage like I really need it to.
    I hope this amount of code will suffice. I think I'm just missing
    something very simple.
    Thanks in advance...


    '///the form
    Public objTAPIline As cTAPI
    Private Sub Form_Load()
    Set objTAPIline = New cTAPI 'Initialize the TAPI class
    objTAPIline.Ini tialize
    'other form stuff here
    End Sub
    Private Sub cmdDial_Click()
    'dial functions here
    objTAPIline.Sta rtMessagePump Me.hwnd
    End Sub

    '///tapi module
    'a zillion declarations
    Public Sub _
    TimerHandler( _
    ByVal hwnd As Long, _
    ByVal uMsg As Integer, _
    ByVal idEvent As Integer, _
    ByVal dwTime As Long)
    'call getlinemessage to check for changes
    frmMain.objTAPI line.GetLineMes sage
    End Sub

    '///tapi class
    'a zillion other functions and such
    'timer declaration some where in here
    Public Sub _
    StartMessagePum p( _
    hwndIn As Long, _
    Optional Interval As Long = 500)
    SetTimer _
    hwndIn, _
    50, _
    Interval, _
    AddressOf TimerHandler
    Debug.Print "starting timer"
    End Sub
    Public Sub _
    StopMessagePump ( _
    hwndIn As Long)
    KillTimer hwndIn, 50
    End Sub
    Public Sub GetLineMessage( )
    'check for events
    End Sub
  • Steve Gerrard

    #2
    Re: Callback issue


    "Jake" <[email protected] t> wrote in message
    news:a3fdc493.0 311092043.6839d [email protected] gle.com...[color=blue]
    > This is a great set of code for TAPI which does everything; however, I am
    > having the worst time trying to figure out why the form is being
    > reinitialized from the timerhandler instead of just calling
    > GetLineMessage like I really need it to.
    > I hope this amount of code will suffice. I think I'm just missing
    > something very simple.
    > Thanks in advance...
    >
    >
    > '///the form
    > Public objTAPIline As cTAPI
    > Private Sub Form_Load()
    > Set objTAPIline = New cTAPI 'Initialize the TAPI class
    > objTAPIline.Ini tialize
    > 'other form stuff here
    > End Sub
    > Private Sub cmdDial_Click()
    > 'dial functions here
    > objTAPIline.Sta rtMessagePump Me.hwnd
    > End Sub
    >
    > '///tapi module
    > 'a zillion declarations
    > Public Sub _
    > TimerHandler( _
    > ByVal hwnd As Long, _
    > ByVal uMsg As Integer, _
    > ByVal idEvent As Integer, _
    > ByVal dwTime As Long)
    > 'call getlinemessage to check for changes
    > frmMain.objTAPI line.GetLineMes sage
    > End Sub
    >
    > '///tapi class
    > 'a zillion other functions and such
    > 'timer declaration some where in here
    > Public Sub _
    > StartMessagePum p( _
    > hwndIn As Long, _
    > Optional Interval As Long = 500)
    > SetTimer _
    > hwndIn, _
    > 50, _
    > Interval, _
    > AddressOf TimerHandler
    > Debug.Print "starting timer"
    > End Sub
    > Public Sub _
    > StopMessagePump ( _
    > hwndIn As Long)
    > KillTimer hwndIn, 50
    > End Sub
    > Public Sub GetLineMessage( )
    > 'check for events
    > End Sub[/color]

    Don't know for sure, but I would try not using frmMain to refer to your main
    form. If it gets called before the form is done loading, it could automatically
    create another instance. Instead, declare a global variable and initialize it in
    Sub Main, and start your project with Sub Main. Also, I would move the StartPump
    call out of the Load event, so the form is definitely done loading and ready for
    callbacks.

    Global gMainForm As frmMain

    Sub Main()

    Set gMainForm = New frmMain

    gMainForm.Show

    DoEvents

    gMainForm.objTA PIline.StartMes sagePump gMainForm.hWnd

    End Sub



    Comment

    Working...