Solved

Use MSComm Control to detect the phone ring...

Posted on 1998-04-10
2
927 Views
Last Modified: 2010-05-18
I would like to use the MSComm to detect the phone ringing. How do I do it? Like sample code, please.
Thanks in advance
0
Comment
Question by:AmyH111
2 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 200 total points
ID: 1460918
AmyH111,
See if this is waht you are after:

Start a new project
Drop a command button, Name it CmdOK
Drop a MSComm control
Drop a timer


Option Explicit

Private Declare Function SetWindowPos% Lib "user" (ByVal win%, ByVal awin%, ByVal xp%, ByVal yp%, ByVal xs%, ByVal ys%, ByVal flags%)

Private Sub Comm1_OnComm()
Static ReceiveBuffer As String
Dim Position As Integer
    ReceiveBuffer = ReceiveBuffer & Comm1.Input
    Position = InStr(ReceiveBuffer, Chr$(13) & Chr$(10))
    If Position Then                         'Parse the message
        If InStr(ReceiveBuffer, "RING") Then PopUpForm
        ReceiveBuffer = Mid$(ReceiveBuffer, Position + 1)
        If Len(ReceiveBuffer) Then Comm1_OnComm  'recurse if required
    End If
End Sub

Private Sub Form_Load()
Dim I As Integer
    On Error Resume Next
    Comm1.PortOpen = True
    If Err Then
        MsgBox "The selected port is not available"
        Unload Me
    End If
    Comm1.RTSEnable = True
    Comm1.RThreshold = 1
    Comm1.Output = "ATV1Q0S0=0" & Chr$(13)
    I = SetWindowPos(Me.hWnd, -2, 0, 0, 0, 0, 3)    'not On Top
    Me.WindowState = 1
End Sub

Private Sub OKbutton_Click()
Dim I As Integer
    I = SetWindowPos(Me.hWnd, -2, 0, 0, 0, 0, 3)
    Me.WindowState = 1
    DoEvents
End Sub

Private Sub PopUpForm()
Dim I As Integer
    Me.WindowState = 0
    I = SetWindowPos(Me.hWnd, -1, 0, 0, 0, 0, 3)  'Set On Top
    Me.Refresh
    DoEvents
    Beep
    MsgBox "Ring....", vbOKOnly, "ring"
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    Timer1.Enabled = False
    OKbutton_Click
End Sub


When the phone ring, the form will come out.
click of, the form minimized.

Good luck
Dalin
0
 

Author Comment

by:AmyH111
ID: 1460919
Thanks
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question