Solved

Use MSComm Control to detect the phone ring...

Posted on 1998-04-10
2
925 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now