tapiRequestMakeCall - How to customize behavior?

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

    tapiRequestMakeCall - How to customize behavior?

    The below code dials a phone number when the subform datasheet cell
    containing the number is double clicked. The problem is that the dialer
    application (c:\windows\dia ler.exe) pops up windows on the screen, requiring
    user intervention to click "Talk" or "Hang Up". I want to customize the
    behavior of the application so that no pop ups are received and the
    application drops the line automatically and closes itself in 6 seconds -
    which is enough time for the user to pick up the phone. The user will hear
    the modem dial, but no other screen alerts will be received. If the phone
    is not picked up with the 6-second window, the call is simply dropped.

    Perhaps I need to write my own custom version of TAPI32.DLL? Or is there a
    way to customize the behavior of this code to suit my needs? I've created
    my own DLLs in the past, though am still somewhat of a novice.

    [Form_frm0Teleph one]
    Option Compare Database
    Option Explicit
    Private Declare Function tapiRequestMake Call Lib "TAPI32.DLL " _
    (ByVal DestAddress As String, ByVal AppName As String, _
    ByVal CalledParty As String, ByVal Comment As String) As Long

    Private Sub Telephone_Numbe rs_DblClick(Can cel As Integer)
    Dim lngRetVal As Long
    Dim strDial As String
    strDial = Forms!frm0!frm0 Telephone.Form! TelNumber
    lngRetVal = tapiRequestMake Call(Trim$(strD ial), "", "", "")
    End Sub

    Thanks in advance.

    PS. thanks to Bruce Thompson and Joacim Andersson for help getting this far.


  • deko

    #2
    Re: tapiRequestMake Call - How to customize behavior?

    > The below code dials a phone number when the subform datasheet cell[color=blue]
    > containing the number is double clicked. The problem is that the dialer
    > application (c:\windows\dia ler.exe) pops up windows on the screen,[/color]
    requiring[color=blue]
    > user intervention to click "Talk" or "Hang Up". I want to customize the
    > behavior of the application so that no pop ups are received and the
    > application drops the line automatically and closes itself in 6 seconds -
    > which is enough time for the user to pick up the phone. The user will[/color]
    hear[color=blue]
    > the modem dial, but no other screen alerts will be received. If the phone
    > is not picked up with the 6-second window, the call is simply dropped.[/color]

    This is close - but how to minimize and close an application (dialer.exe) in
    VBA?

    [Form_frm0Teleph one]
    Option Compare Database
    Option Explicit
    Private Declare Function tapiRequestMake Call Lib "TAPI32.DLL " _
    (ByVal DestAddress As String, ByVal AppName As String, _
    ByVal CalledParty As String, ByVal Comment As String) As Long

    Private Sub Telephone_Numbe rs_DblClick(Can cel As Integer)
    Dim WaitTime As Variant
    Dim Start As Variant
    Dim strDial As String
    Dim lngRetVal As Long
    strDial = Forms!frm0!frm0 Telephone.Form! TelNumber
    lngRetVal = tapiRequestMake Call(Trim$(strD ial), "", "", "")
    'Shell("c:\wind ows\dialer.exe" , 0) '<<=== How to minimize app?
    If lngRetVal <> 0 Then GoTo Exit_Here
    WaitTime = 6
    Start = Timer
    Do While Timer < Start + WaitTime
    DoEvents
    Loop
    Exit_Here:
    'Close "c:\windows\dia ler.exe" '<<=== How to close app?
    End Sub


    Comment

    • PC Datasheet

      #3
      Re: tapiRequestMake Call - How to customize behavior?

      From my file - I haven't tried it!

      If you get it to work, please email me a copy of your code.

      --
      PC Datasheet
      Your Resource For Help With Access, Excel And Word Applications
      resource@pcdata sheet.com


      Dial Telephone Numbers From A Form



      Note: Windows Dialer must be loaded on the machine for this code to work....

      In the Form Module

      Private Sub Phone1_DblClick (Cancel As Integer)
      Call CtrDialer_Click
      End Sub


      In a New Module

      Public Sub CtrDialer_Click ()
      On Error GoTo Err_CtrDialer_C lick

      Dim stDialStr As String
      Dim PrevCtl As Control
      Const ERR_OBJNOTEXIST = 2467
      Const ERR_OBJNOTSET = 91

      Set PrevCtl = Screen.ActiveCo ntrol

      If TypeOf PrevCtl Is TextBox Then
      stDialStr = IIf(varType(Pre vCtl) > V_NULL, PrevCtl, "")
      ElseIf TypeOf PrevCtl Is ListBox Then
      stDialStr = IIf(varType(Pre vCtl) > V_NULL, PrevCtl, "")
      ElseIf TypeOf PrevCtl Is ComboBox Then
      stDialStr = IIf(varType(Pre vCtl) > V_NULL, PrevCtl, "")
      Else
      stDialStr = ""
      End If

      Application.Run "utility.wlib_A utoDial", stDialStr


      Exit_CtrDialer_ Click:
      Exit Sub

      Err_CtrDialer_C lick:
      If (Err = ERR_OBJNOTEXIST ) Or (Err = ERR_OBJNOTSET) Then
      Resume Next
      End If
      MsgBox Err.Description
      Resume Exit_CtrDialer_ Click

      End Sub


      "deko" <deko@hotmail.c om> wrote in message
      news:48Kec.3627 5$Uc1.35745@new ssvr29.news.pro digy.com...[color=blue]
      > The below code dials a phone number when the subform datasheet cell
      > containing the number is double clicked. The problem is that the dialer
      > application (c:\windows\dia ler.exe) pops up windows on the screen, requiring
      > user intervention to click "Talk" or "Hang Up". I want to customize the
      > behavior of the application so that no pop ups are received and the
      > application drops the line automatically and closes itself in 6 seconds -
      > which is enough time for the user to pick up the phone. The user will hear
      > the modem dial, but no other screen alerts will be received. If the phone
      > is not picked up with the 6-second window, the call is simply dropped.
      >
      > Perhaps I need to write my own custom version of TAPI32.DLL? Or is there a
      > way to customize the behavior of this code to suit my needs? I've created
      > my own DLLs in the past, though am still somewhat of a novice.
      >
      > [Form_frm0Teleph one]
      > Option Compare Database
      > Option Explicit
      > Private Declare Function tapiRequestMake Call Lib "TAPI32.DLL " _
      > (ByVal DestAddress As String, ByVal AppName As String, _
      > ByVal CalledParty As String, ByVal Comment As String) As Long
      >
      > Private Sub Telephone_Numbe rs_DblClick(Can cel As Integer)
      > Dim lngRetVal As Long
      > Dim strDial As String
      > strDial = Forms!frm0!frm0 Telephone.Form! TelNumber
      > lngRetVal = tapiRequestMake Call(Trim$(strD ial), "", "", "")
      > End Sub
      >
      > Thanks in advance.
      >
      > PS. thanks to Bruce Thompson and Joacim Andersson for help getting this far.
      >
      >[/color]


      Comment

      • deko

        #4
        Re: tapiRequestMake Call - How to customize behavior?

        > If you get it to work, please email me a copy of your code.

        This code is effective for closing the pop up windows, but it won't close
        the app - Dialer.exe. Apparently the AppCaption is not what appears in the
        window header of the application window - i.e. "Phone Dialer". Is there a
        way to find the caption programmaticall y? Perhaps there is an easier way to
        simply close an application in VB. There must be. When I find that
        solution, I'll probably modify the below code to hide (rather than close)
        the pop up windows and then close (cleanly) Dialer.exe (and by association
        the popups) after the 6-second WaitTime.

        Option Compare Database
        Option Explicit
        'API Find applcation by full caption
        Private Declare Function FindWindow _
        Lib "user32" _
        Alias "FindWindow A" _
        ( _
        ByVal lpClassName As String, _
        ByVal lpWindowName As String _
        ) _
        As Long

        'API Bring Window to foreground
        Private Declare Function SetForegroundWi ndow _
        Lib "user32" _
        ( _
        ByVal hwnd As Long _
        ) _
        As Long

        'API Send message to application
        Private Declare Function PostMessage _
        Lib "user32" _
        Alias "PostMessag eA" _
        ( _
        ByVal hwnd As Long, _
        ByVal wMsg As Long, _
        ByVal wParam As Long, _
        lParam As Any _
        ) _
        As Long

        Const WM_CLOSE = &H10

        Function Close_By_Captio n(AppCaption As String)
        Dim hwnd As Long
        hwnd = FindWindow(vbNu llString, AppCaption)
        If hwnd Then
        'Bring to Front
        SetForegroundWi ndow hwnd
        'Close the app nicely
        PostMessage hwnd, WM_CLOSE, 0&, 0&
        End If
        End Function

        Private Sub cmdTest_Click()
        'Close_By_Capti on ("Dialing") - works great
        'Close_By_Capti on ("Call Status") - works great
        Colse_By_Captio n ("Phone Dialer") - does not work
        End Sub


        Comment

        • MGFoster

          #5
          Re: tapiRequestMake Call - How to customize behavior?

          deko wrote:
          [color=blue][color=green]
          >>If you get it to work, please email me a copy of your code.[/color]
          >
          >
          > This code is effective for closing the pop up windows, but it won't close
          > the app - Dialer.exe. Apparently the AppCaption is not what appears in the
          > window header of the application window - i.e. "Phone Dialer". Is there a
          > way to find the caption programmaticall y? Perhaps there is an easier way to
          > simply close an application in VB. There must be. When I find that
          > solution, I'll probably modify the below code to hide (rather than close)
          > the pop up windows and then close (cleanly) Dialer.exe (and by association
          > the popups) after the 6-second WaitTime.
          >[/color]
          < SNIP >

          -----BEGIN PGP SIGNED MESSAGE-----
          Hash: SHA1

          Why not use the code found here instead of the Dialer.exe method.

          ACC: How to Dial a Phone Number from MS Access 95/97



          --
          MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
          Oakland, CA (USA)

          -----BEGIN PGP SIGNATURE-----
          Version: PGP for Personal Privacy 5.0
          Charset: noconv

          iQA/AwUBQHwkL4echKq OuFEgEQLDAQCgnX 02cV7FYpM8h70V8 FAhEyOV4ggAoNfp
          p9lGoUPu5F5haOA ot3Lh6RaE
          =Yb1F
          -----END PGP SIGNATURE-----

          Comment

          • deko

            #6
            Re: tapiRequestMake Call - How to customize behavior?

            > Why not use the code found here instead of the Dialer.exe method.[color=blue]
            >
            > ACC: How to Dial a Phone Number from MS Access 95/97
            >
            > http://support.microsoft.com/default...b;en-us;148857[/color]

            I looked at that code - not sure if it will make use of Dialing Properties,
            and I think using the TAPI interface is a better solution.

            The below code works - my only complaint is that I can't hide the "Call
            Status" window. I'm sure my syntax is wrong somewhere... not sure where.
            Keep getting Error Number 49: Bad DLL calling convention...

            Option Compare Database
            Option Explicit
            Const WM_CLOSE = &H10
            'Const SW_HIDE = 0

            'API use Phone Dialer to make call (default dialer)
            Private Declare Function tapiRequestMake Call _
            Lib "TAPI32.DLL " _
            ( _
            ByVal DestAddress As String, _
            ByVal AppName As String, _
            ByVal CalledParty As String, _
            ByVal Comment As String _
            ) _
            As Long

            'API find applcation by full caption
            Private Declare Function FindWindow _
            Lib "user32" _
            Alias "FindWindow A" _
            ( _
            ByVal lpClassName As String, _
            ByVal lpWindowName As String _
            ) _
            As Long

            'API bring Window to foreground
            Private Declare Function SetForegroundWi ndow _
            Lib "user32" _
            ( _
            ByVal hwnd As Long _
            ) _
            As Long

            'API set ShowWindow to hide window
            Private Declare Function ShowWindow _
            Lib "user32" _
            ( _
            ByVal hwnd As Long, _
            ByVal nCmdShow As Integer _
            )

            'API send message to application
            Private Declare Function PostMessage _
            Lib "user32" _
            Alias "PostMessag eA" _
            ( _
            ByVal hwnd As Long, _
            ByVal wMsg As Long, _
            ByVal wParam As Long, _
            lParam As Any _
            ) _
            As Long

            Private Function Hide_Window(App Caption As String)
            Dim hwnd As Long
            hwnd = FindWindow(vbNu llString, AppCaption)
            If hwnd Then
            Debug.Print hwnd
            Debug.Print AppCaption
            ShowWindow hwnd, 0
            End If
            End Function

            'not using this function
            Private Function Close_By_Captio n(AppCaption As String)
            Dim hwnd As Long
            hwnd = FindWindow(vbNu llString, AppCaption)
            If hwnd Then
            'Bring to Front
            SetForegroundWi ndow hwnd
            'Close the app nicely
            PostMessage hwnd, WM_CLOSE, 0&, 0&
            End If
            Exit_Here:
            Exit Function
            HandleErr:
            Select Case Err.Number
            Case Else
            modHandler.LogE rr ("frm0Telephone "), ("Close_By_Capt ion")
            End Select
            Resume Exit_Here
            End Function

            Private Function CloseAPP(AppNam eOfExe As String, _
            Optional KillAll As Boolean = False, _
            Optional NeedYesNo As Boolean = True) _
            As Boolean
            Dim oProcList As Object
            Dim oWMI As Object
            Dim oProc As Object
            CloseAPP = False
            'create WMI object instance:
            Set oWMI = GetObject("winm gmts:")
            If IsNull(oWMI) = False Then
            'create object collection of Win32 processes:
            Set oProcList = oWMI.InstancesO f("win32_proces s")
            'iterate through the enumerated collection:
            For Each oProc In oProcList
            'Debug.Print oProc.Name
            'option to close a process:
            If UCase(oProc.Nam e) = UCase(AppNameOf Exe) Then
            NeedYesNo = False 'don't wan't msgbox
            If NeedYesNo Then
            If MsgBox("Kill " & oProc.Name & vbNewLine & "Are you
            sure?", _
            vbYesNo + vbCritical) = vbYes Then
            oProc.Terminate (0)
            CloseAPP = True
            End If
            Else
            oProc.Terminate (0)
            CloseAPP = True
            End If
            'continue search for more?
            If Not KillAll And CloseAPP Then
            Exit For 'oProc In oProcList
            End If
            End If
            Next
            Else
            'report error
            End If
            Exit_Here:
            Set oProcList = Nothing
            Set oWMI = Nothing
            Exit Function
            HandleErr:
            Select Case Err.Number
            Case Else
            modHandler.LogE rr ("frm0Telephone "), ("Close_APP" )
            End Select
            Resume Exit_Here
            End Function

            Private Sub Telephone_Numbe rs_DblClick(Can cel As Integer)
            On Error GoTo HandleErr
            Dim varDialWait As Variant
            Dim varStart As Variant
            Dim strDial As String
            Dim lngRetVal As Long
            Static blnDialing As Boolean 'prevent reentry into sub while dialing
            DoEvents
            blnDialing = False
            If blnDialing Then Exit Sub
            blnDialing = True
            strDial = Forms!frm0!frm0 Telephone.Form! TelNumber
            lngRetVal = tapiRequestMake Call(Trim$(strD ial), "", "", "")
            If lngRetVal <> 0 Then Exit Sub
            varDialWait = DLookup("DialWa it", "tblPrefs")
            varStart = Timer
            Do While Timer < varStart + varDialWait
            DoEvents
            'Hide_Window ("Call Status") '<<=== this fails with Error Number 49:
            Bad DLL calling convention
            Loop
            Exit_Here:
            On Error Resume Next
            blnDialing = False
            CloseAPP ("dialer.exe ")
            Exit Sub
            HandleErr:
            Select Case Err.Number
            Case 94 'Invalid Use of Null - if double click on blank, open dialer
            Call Shell("c:\windo ws\dialer.exe", vbNormalFocus)
            blnDialing = False
            Exit Sub
            Case Else
            modHandler.LogE rr ("frm0Telephone "),
            ("Telephone_Num bers_DblClick")
            End Select
            Resume Exit_Here
            End Sub


            Comment

            • Stephen Lebans

              #7
              Re: tapiRequestMake Call - How to customize behavior?

              You can use SPY++ if you have VC++( or I think even VB) on your system
              to determine the Class name of the offending Dialog. Modify your code to
              find the window by Class name instead of Caption.

              If you do not have SPY++ send me a functioning MDB and I'll post the
              Class name for the Dialog.

              --

              HTH
              Stephen Lebans

              Access Code, Tips and Tricks
              Please respond only to the newsgroups so everyone can benefit.


              "deko" <deko@hotmail.c om> wrote in message
              news:WjYec.5110 9$%x2.34508@new ssvr25.news.pro digy.com...[color=blue][color=green]
              > > Why not use the code found here instead of the Dialer.exe method.
              > >
              > > ACC: How to Dial a Phone Number from MS Access 95/97
              > >
              > > http://support.microsoft.com/default...b;en-us;148857[/color]
              >
              > I looked at that code - not sure if it will make use of Dialing[/color]
              Properties,[color=blue]
              > and I think using the TAPI interface is a better solution.
              >
              > The below code works - my only complaint is that I can't hide the[/color]
              "Call[color=blue]
              > Status" window. I'm sure my syntax is wrong somewhere... not sure[/color]
              where.[color=blue]
              > Keep getting Error Number 49: Bad DLL calling convention...
              >
              > Option Compare Database
              > Option Explicit
              > Const WM_CLOSE = &H10
              > 'Const SW_HIDE = 0
              >
              > 'API use Phone Dialer to make call (default dialer)
              > Private Declare Function tapiRequestMake Call _
              > Lib "TAPI32.DLL " _
              > ( _
              > ByVal DestAddress As String, _
              > ByVal AppName As String, _
              > ByVal CalledParty As String, _
              > ByVal Comment As String _
              > ) _
              > As Long
              >
              > 'API find applcation by full caption
              > Private Declare Function FindWindow _
              > Lib "user32" _
              > Alias "FindWindow A" _
              > ( _
              > ByVal lpClassName As String, _
              > ByVal lpWindowName As String _
              > ) _
              > As Long
              >
              > 'API bring Window to foreground
              > Private Declare Function SetForegroundWi ndow _
              > Lib "user32" _
              > ( _
              > ByVal hwnd As Long _
              > ) _
              > As Long
              >
              > 'API set ShowWindow to hide window
              > Private Declare Function ShowWindow _
              > Lib "user32" _
              > ( _
              > ByVal hwnd As Long, _
              > ByVal nCmdShow As Integer _
              > )
              >
              > 'API send message to application
              > Private Declare Function PostMessage _
              > Lib "user32" _
              > Alias "PostMessag eA" _
              > ( _
              > ByVal hwnd As Long, _
              > ByVal wMsg As Long, _
              > ByVal wParam As Long, _
              > lParam As Any _
              > ) _
              > As Long
              >
              > Private Function Hide_Window(App Caption As String)
              > Dim hwnd As Long
              > hwnd = FindWindow(vbNu llString, AppCaption)
              > If hwnd Then
              > Debug.Print hwnd
              > Debug.Print AppCaption
              > ShowWindow hwnd, 0
              > End If
              > End Function
              >
              > 'not using this function
              > Private Function Close_By_Captio n(AppCaption As String)
              > Dim hwnd As Long
              > hwnd = FindWindow(vbNu llString, AppCaption)
              > If hwnd Then
              > 'Bring to Front
              > SetForegroundWi ndow hwnd
              > 'Close the app nicely
              > PostMessage hwnd, WM_CLOSE, 0&, 0&
              > End If
              > Exit_Here:
              > Exit Function
              > HandleErr:
              > Select Case Err.Number
              > Case Else
              > modHandler.LogE rr ("frm0Telephone "), ("Close_By_Capt ion")
              > End Select
              > Resume Exit_Here
              > End Function
              >
              > Private Function CloseAPP(AppNam eOfExe As String, _
              > Optional KillAll As Boolean = False, _
              > Optional NeedYesNo As Boolean = True) _
              > As Boolean
              > Dim oProcList As Object
              > Dim oWMI As Object
              > Dim oProc As Object
              > CloseAPP = False
              > 'create WMI object instance:
              > Set oWMI = GetObject("winm gmts:")
              > If IsNull(oWMI) = False Then
              > 'create object collection of Win32 processes:
              > Set oProcList = oWMI.InstancesO f("win32_proces s")
              > 'iterate through the enumerated collection:
              > For Each oProc In oProcList
              > 'Debug.Print oProc.Name
              > 'option to close a process:
              > If UCase(oProc.Nam e) = UCase(AppNameOf Exe) Then
              > NeedYesNo = False 'don't wan't msgbox
              > If NeedYesNo Then
              > If MsgBox("Kill " & oProc.Name & vbNewLine & "Are[/color]
              you[color=blue]
              > sure?", _
              > vbYesNo + vbCritical) = vbYes Then
              > oProc.Terminate (0)
              > CloseAPP = True
              > End If
              > Else
              > oProc.Terminate (0)
              > CloseAPP = True
              > End If
              > 'continue search for more?
              > If Not KillAll And CloseAPP Then
              > Exit For 'oProc In oProcList
              > End If
              > End If
              > Next
              > Else
              > 'report error
              > End If
              > Exit_Here:
              > Set oProcList = Nothing
              > Set oWMI = Nothing
              > Exit Function
              > HandleErr:
              > Select Case Err.Number
              > Case Else
              > modHandler.LogE rr ("frm0Telephone "), ("Close_APP" )
              > End Select
              > Resume Exit_Here
              > End Function
              >
              > Private Sub Telephone_Numbe rs_DblClick(Can cel As Integer)
              > On Error GoTo HandleErr
              > Dim varDialWait As Variant
              > Dim varStart As Variant
              > Dim strDial As String
              > Dim lngRetVal As Long
              > Static blnDialing As Boolean 'prevent reentry into sub while[/color]
              dialing[color=blue]
              > DoEvents
              > blnDialing = False
              > If blnDialing Then Exit Sub
              > blnDialing = True
              > strDial = Forms!frm0!frm0 Telephone.Form! TelNumber
              > lngRetVal = tapiRequestMake Call(Trim$(strD ial), "", "", "")
              > If lngRetVal <> 0 Then Exit Sub
              > varDialWait = DLookup("DialWa it", "tblPrefs")
              > varStart = Timer
              > Do While Timer < varStart + varDialWait
              > DoEvents
              > 'Hide_Window ("Call Status") '<<=== this fails with Error[/color]
              Number 49:[color=blue]
              > Bad DLL calling convention
              > Loop
              > Exit_Here:
              > On Error Resume Next
              > blnDialing = False
              > CloseAPP ("dialer.exe ")
              > Exit Sub
              > HandleErr:
              > Select Case Err.Number
              > Case 94 'Invalid Use of Null - if double click on blank, open[/color]
              dialer[color=blue]
              > Call Shell("c:\windo ws\dialer.exe", vbNormalFocus)
              > blnDialing = False
              > Exit Sub
              > Case Else
              > modHandler.LogE rr ("frm0Telephone "),
              > ("Telephone_Num bers_DblClick")
              > End Select
              > Resume Exit_Here
              > End Sub
              >
              >[/color]

              Comment

              • deko

                #8
                Re: tapiRequestMake Call - How to customize behavior?

                > If you do not have SPY++ send me a functioning MDB and I'll post the[color=blue]
                > Class name for the Dialog.[/color]

                Hi Stephen,

                It's on it's way...

                Thanks!


                Comment

                • Dimitri Furman

                  #9
                  Re: tapiRequestMake Call - How to customize behavior?

                  On Apr 13 2004, 05:05 pm, "Stephen Lebans" <ForEmailGotoMy .WebSite.-
                  WWWdotlebansdot com@linvalid.co m> wrote in news:lCYec.1797 8$Np3.635507@ur sa-
                  nb00s0.nbnet.nb .ca:
                  [color=blue]
                  > You can use SPY++ if you have VC++( or I think even VB) on your system
                  > to determine the Class name of the offending Dialog. Modify your code to
                  > find the window by Class name instead of Caption.
                  >[/color]

                  Or, if you don't have Spy++, you can use Wintree from


                  --
                  remove a 9 to reply by email

                  Comment

                  • Stephen Lebans

                    #10
                    Re: tapiRequestMake Call - How to customize behavior?

                    A couple of errors in your API declarations seem to be the problem. The
                    second ShowWindow param should be a Long not Integer.
                    Notice I changed the last SendMessage param to ByValue instead of ByRef.
                    You were passing a 0 which is interpreted as the memory location at
                    address ZERO.
                    Also remember that hWnds can be negative in WinNT or higher so the
                    standard check is against 0.

                    I have tested the code below and it works.


                    Option Compare Database
                    Option Explicit
                    Const WM_CLOSE = &H10
                    'Const SW_HIDE = 0

                    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
                    Long)


                    'API use Phone Dialer to make call
                    Private Declare Function tapiRequestMake Call _
                    Lib "TAPI32.DLL " _
                    ( _
                    ByVal DestAddress As String, _
                    ByVal AppName As String, _
                    ByVal CalledParty As String, _
                    ByVal Comment As String _
                    ) _
                    As Long

                    'API find applcation by full caption
                    Private Declare Function FindWindow _
                    Lib "user32" _
                    Alias "FindWindow A" _
                    ( _
                    ByVal lpClassName As String, _
                    ByVal lpWindowName As String _
                    ) _
                    As Long

                    'API bring Window to foreground
                    Private Declare Function SetForegroundWi ndow _
                    Lib "user32" _
                    ( _
                    ByVal hwnd As Long _
                    ) _
                    As Long

                    'API set ShowWindow to hide window
                    Private Declare Function ShowWindow _
                    Lib "user32" _
                    ( _
                    ByVal hwnd As Long, _
                    ByVal nCmdShow As Long _
                    )

                    'API send message to application
                    Private Declare Function PostMessage _
                    Lib "user32" _
                    Alias "PostMessag eA" _
                    ( _
                    ByVal hwnd As Long, _
                    ByVal wMsg As Long, _
                    ByVal wParam As Long, _
                    ByVal lParam As Long _
                    ) _
                    As Long
                    Private Function Hide_Window(App Caption As String)
                    Dim hwnd As Long
                    hwnd = FindWindow(vbNu llString, AppCaption)
                    If hwnd Then
                    Debug.Print hwnd
                    Debug.Print AppCaption
                    ShowWindow hwnd, 0
                    End If
                    End Function
                    Private Function Close_By_Captio n(AppCaption As String)
                    Dim hwnd As Long
                    hwnd = FindWindow(vbNu llString, AppCaption)
                    If hwnd <> 0 Then
                    'Bring to Front
                    SetForegroundWi ndow hwnd
                    'Close the app nicely
                    PostMessage hwnd, WM_CLOSE, 0&, 0&
                    End If
                    Exit_Here:
                    Exit Function
                    HandleErr:
                    Select Case Err.Number
                    Case Else
                    'modHandler.Log Err ("frm0Telephone "), ("Close_By_Capt ion")
                    End Select
                    Resume Exit_Here
                    End Function
                    Private Function CloseAPP(AppNam eOfExe As String, _
                    Optional KillAll As Boolean = False, _
                    Optional NeedYesNo As Boolean = True) _
                    As Boolean
                    Dim oProcList As Object
                    Dim oWMI As Object
                    Dim oProc As Object
                    CloseAPP = False
                    'create WMI object instance:
                    Set oWMI = GetObject("winm gmts:")
                    If IsNull(oWMI) = False Then
                    'create object collection of Win32 processes:
                    Set oProcList = oWMI.InstancesO f("win32_proces s")
                    'iterate through the enumerated collection:
                    For Each oProc In oProcList
                    'Debug.Print oProc.Name
                    'option to close a process:
                    If UCase(oProc.Nam e) = UCase(AppNameOf Exe) Then
                    NeedYesNo = False 'don't wan't msgbox
                    If NeedYesNo Then
                    If MsgBox("Kill " & oProc.Name & vbNewLine & "Are
                    you sure?", _
                    vbYesNo + vbCritical) = vbYes Then
                    oProc.Terminate (0)
                    CloseAPP = True
                    End If
                    Else
                    oProc.Terminate (0)
                    CloseAPP = True
                    End If
                    'continue search for more?
                    If Not KillAll And CloseAPP Then
                    Exit For 'oProc In oProcList
                    End If
                    End If
                    Next
                    Else
                    'report error
                    End If
                    Exit_Here:
                    Set oProcList = Nothing
                    Set oWMI = Nothing
                    Exit Function
                    HandleErr:
                    Select Case Err.Number
                    Case Else
                    'modHandler.Log Err ("frm0Telephone "), ("Close_APP" )
                    End Select
                    Resume Exit_Here
                    End Function
                    Private Sub Telephone_Numbe rs_DblClick(Can cel As Integer)
                    On Error GoTo HandleErr
                    Dim varDialWait As Variant
                    Dim varStart As Variant
                    Dim strDial As String
                    Dim lngRetVal As Long
                    Static blnDialing As Boolean 'prevent reentry into sub while dialing
                    DoEvents
                    blnDialing = False
                    If blnDialing Then Exit Sub
                    strDial = Me.TelNumber
                    lngRetVal = tapiRequestMake Call(Trim$(strD ial), "", "", "")
                    If lngRetVal = 0 Then
                    blnDialing = True
                    'varDialWait = DLookup("DialWa it", "tblPrefs")
                    'varDialWait = 8
                    Dim strMsg As String
                    Dim varReturn As Long, lngX As Long
                    strMsg = "You have 10 seconds to Pick up the Phone to Talk!" &
                    "..."
                    varReturn = SysCmd(acSysCmd InitMeter, strMsg, 10)
                    ' Display message in status bar.
                    For lngX = 1 To 10
                    varReturn = SysCmd(acSysCmd UpdateMeter, lngX)
                    ' Update meter.
                    Sleep 1000 ' sleep 1 second

                    Next lngX
                    varReturn = SysCmd(acSysCmd ClearStatus)




                    'For x = 1 To 6
                    'Me.statusbar = "...... 6 seconds to Pick up the Phone"

                    'varStart = Timer
                    'Do While Timer < varStart + varDialWait
                    ' DoEvents
                    'Hide_Window ("Call Status") '<<=== this fails with Error
                    Number 49: Bad DLL calling convention
                    ' Loop
                    End If
                    Exit_Here:
                    blnDialing = False
                    Close_By_Captio n ("Dialing") ' - works great
                    Close_By_Captio n ("Call Status") '- works great
                    Close_By_Captio n ("Phone Dialer") ' - does

                    'CloseAPP ("dialer.exe ")
                    Exit Sub
                    HandleErr:
                    Select Case Err.Number
                    Case 94 'Invalid Use of Null - if double-click on blank, open
                    dialer
                    Call Shell("c:\windo ws\dialer.exe", vbNormalFocus)
                    Exit Sub
                    Case Else
                    'modHandler.Log Err ("frm0Telephone "),
                    ("Telephone_Num bers_DblClick")
                    End Select
                    Resume Exit_Here
                    End Sub


                    --

                    HTH
                    Stephen Lebans

                    Access Code, Tips and Tricks
                    Please respond only to the newsgroups so everyone can benefit.


                    "deko" <deko@hotmail.c om> wrote in message
                    news:eQ_ec.3662 0$gN7.10697@new ssvr29.news.pro digy.com...[color=blue][color=green]
                    > > If you do not have SPY++ send me a functioning MDB and I'll post the
                    > > Class name for the Dialog.[/color]
                    >
                    > Hi Stephen,
                    >
                    > It's on it's way...
                    >
                    > Thanks!
                    >
                    >[/color]

                    Comment

                    • Stephen Lebans

                      #11
                      Re: tapiRequestMake Call - How to customize behavior?

                      Very cool Dimitri!!
                      :-)

                      Though I would remove the credit to Walker... he get too much credit as
                      it is!<grin>
                      (Hi Peter)

                      --
                      Stephen Lebans

                      Access Code, Tips and Tricks
                      Please respond only to the newsgroups so everyone can benefit.


                      "Dimitri Furman" <dfurman@cloud9 9.net> wrote in message
                      news:Xns94CAD10 B8F85Cdfurmancl oud99@127.0.0.1 ...[color=blue]
                      > On Apr 13 2004, 05:05 pm, "Stephen Lebans" <ForEmailGotoMy .WebSite.-
                      > WWWdotlebansdot com@linvalid.co m> wrote in[/color]
                      news:lCYec.1797 8$Np3.635507@ur sa-[color=blue]
                      > nb00s0.nbnet.nb .ca:
                      >[color=green]
                      > > You can use SPY++ if you have VC++( or I think even VB) on your[/color][/color]
                      system[color=blue][color=green]
                      > > to determine the Class name of the offending Dialog. Modify your[/color][/color]
                      code to[color=blue][color=green]
                      > > find the window by Class name instead of Caption.
                      > >[/color]
                      >
                      > Or, if you don't have Spy++, you can use Wintree from
                      > http://www.users.cloud9.net/~dfurman/code.htm
                      >
                      > --
                      > remove a 9 to reply by email[/color]

                      Comment

                      • deko

                        #12
                        Re: tapiRequestMake Call - How to customize behavior?

                        Thanks. The status bar meter is a nice touch. Appreciate the help.
                        [color=blue]
                        > You were passing a 0 which is interpreted as the memory location at
                        > address ZERO.[/color]

                        SW_HIDE is supposed to hide the window - I thought SW_HIDE is a constant for
                        0... what then to pass?

                        Private Declare Function ShowWindow _
                        Lib "user32" _
                        ( _
                        ByVal hwnd As Long, _
                        ByVal nCmdShow As Long _
                        )

                        Private Function Hide_Window(App Caption As String)
                        Dim hwnd As Long
                        hwnd = FindWindow(vbNu llString, AppCaption)
                        If hwnd Then
                        ShowWindow hwnd, 0 '<<=== if not 0, then what?
                        End If
                        End Function

                        Private Sub HideCallStatus( )
                        Hide_Window ("Call Status")
                        End Sub


                        Comment

                        • Stephen Lebans

                          #13
                          Re: tapiRequestMake Call - How to customize behavior?

                          For the ShowWindow API I said the second param should be declared as
                          Long not Integer.

                          The ByVal vs ByRef issue was for the PostMessage API declaration.

                          :-)
                          --
                          HTH
                          Stephen Lebans

                          Access Code, Tips and Tricks
                          Please respond only to the newsgroups so everyone can benefit.


                          "deko" <deko@hotmail.c om> wrote in message
                          news:qL0fc.3664 0$QE.19839@news svr29.news.prod igy.com...[color=blue]
                          > Thanks. The status bar meter is a nice touch. Appreciate the help.
                          >[color=green]
                          > > You were passing a 0 which is interpreted as the memory location at
                          > > address ZERO.[/color]
                          >
                          > SW_HIDE is supposed to hide the window - I thought SW_HIDE is a[/color]
                          constant for[color=blue]
                          > 0... what then to pass?
                          >
                          > Private Declare Function ShowWindow _
                          > Lib "user32" _
                          > ( _
                          > ByVal hwnd As Long, _
                          > ByVal nCmdShow As Long _
                          > )
                          >
                          > Private Function Hide_Window(App Caption As String)
                          > Dim hwnd As Long
                          > hwnd = FindWindow(vbNu llString, AppCaption)
                          > If hwnd Then
                          > ShowWindow hwnd, 0 '<<=== if not 0, then what?
                          > End If
                          > End Function
                          >
                          > Private Sub HideCallStatus( )
                          > Hide_Window ("Call Status")
                          > End Sub
                          >
                          >[/color]

                          Comment

                          • Dimitri Furman

                            #14
                            Re: tapiRequestMake Call - How to customize behavior?

                            On Apr 13 2004, 09:16 pm, "Stephen Lebans" <ForEmailGotoMy .WebSite.-
                            WWWdotlebansdot com@linvalid.co m> wrote in news:ci0fc.1820 8$Np3.641838@ur sa-
                            nb00s0.nbnet.nb .ca:
                            [color=blue]
                            > Very cool Dimitri!!
                            >:-)
                            >
                            > Though I would remove the credit to Walker... he get too much credit as
                            > it is!<grin>
                            > (Hi Peter)
                            >[/color]

                            Thanks Stephen! I had too much time on my hands at one point <g>

                            Peter deserves the credit though - he posted something that gave me the
                            idea, so I started to fool with it, only to discover the existence of Spy++
                            a week after I was done with the thing... Well, at least it does delayed
                            window snapshots, which I don't think you can do with Spy++.

                            --
                            remove a 9 to reply by email

                            Comment

                            • Stephen Lebans

                              #15
                              Re: tapiRequestMake Call - How to customize behavior?

                              I know the feeling Dimitri!
                              :-)
                              Peter's posts have started several of my projects as well.
                              :-)
                              --

                              HTH
                              Stephen Lebans

                              Access Code, Tips and Tricks
                              Please respond only to the newsgroups so everyone can benefit.


                              "Dimitri Furman" <dfurman@cloud9 9.net> wrote in message
                              news:Xns94CAE26 2C8810dfurmancl oud99@127.0.0.1 ...[color=blue]
                              > On Apr 13 2004, 09:16 pm, "Stephen Lebans" <ForEmailGotoMy .WebSite.-
                              > WWWdotlebansdot com@linvalid.co m> wrote in[/color]
                              news:ci0fc.1820 8$Np3.641838@ur sa-[color=blue]
                              > nb00s0.nbnet.nb .ca:
                              >[color=green]
                              > > Very cool Dimitri!!
                              > >:-)
                              > >
                              > > Though I would remove the credit to Walker... he get too much credit[/color][/color]
                              as[color=blue][color=green]
                              > > it is!<grin>
                              > > (Hi Peter)
                              > >[/color]
                              >
                              > Thanks Stephen! I had too much time on my hands at one point <g>
                              >
                              > Peter deserves the credit though - he posted something that gave me[/color]
                              the[color=blue]
                              > idea, so I started to fool with it, only to discover the existence of[/color]
                              Spy++[color=blue]
                              > a week after I was done with the thing... Well, at least it does[/color]
                              delayed[color=blue]
                              > window snapshots, which I don't think you can do with Spy++.
                              >
                              > --
                              > remove a 9 to reply by email[/color]

                              Comment

                              Working...