Solved

Use MSComm Control to detect the phone ring...

Posted on 1998-04-10
2
918 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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

771 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

11 Experts available now in Live!

Get 1:1 Help Now