⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmdial.frm

📁 监控类的开发
💻 FRM
📖 第 1 页 / 共 4 页
字号:
        End If
    End With
End Sub

Public Sub ShowGrid()
    On Error Resume Next
    
    With AdodcDial
        If nGridShow = SHOW_PHONEBOOK Then
            Me.Caption = "Dialer -- Phone Book"
            DG_PhoneBook.ZOrder 0
            DG_CallIn.ZOrder 1
            
            .CommandType = adCmdUnknown
            .RecordSource = "select * from PhoneBook order by [ID]"
            .Refresh
            If .Recordset.RecordCount > 0 Then .Recordset.MoveFirst
            
            cmdSave.Visible = True
            cmdCount.Visible = False
        End If
        
        If nGridShow = SHOW_CALLIN Then
            Me.Caption = "Dialer -- Call In"
            DG_CallIn.ZOrder 0
            DG_PhoneBook.ZOrder 1
            
            .CommandType = adCmdUnknown
            .RecordSource = "select * from CallIn order by [ID]"
            .Refresh
            If .Recordset.RecordCount > 0 Then .Recordset.MoveLast
            
            cmdCount.Visible = True
            cmdSave.Visible = False
        End If
    End With
End Sub

Private Sub SetPortNoAndTest(nPort As Integer)
  On Error Resume Next
  
  CloseMsComm MSComm1, 50
  
  MSComm1.CommPort = nPort
  
  OpenMsComm MSComm1, 100
  MSComm1.Output = "ATS0=15" + Chr(13)
End Sub

Public Function FindLastName(strPhone As String) As String
    'Get the lastest name by phone number.
    On Error Resume Next
    
    If strPhone = "" Then Exit Function
    
    With AdodcDial
        .RecordSource = "select * from CallIn where [Phone]='" + strPhone + "' order by [Date],[Time]"
        .Refresh
        With .Recordset
            If .RecordCount < 1 Then Exit Function
            .MoveLast
            FindLastName = Trim(![Name])
        End With
    End With
    
    ShowGrid
End Function

Private Sub ChangeIcon(nIcon As Integer)
  Dim strTime As String
  strTime = GetNoString(strStartTime, ":", 0) + ":" + GetNoString(strStartTime, ":", 1)
  strTime = "Start: " + strTime
  
  If nIcon = ICON_ON Then
    nID.szTip = "Dialer: ON" + Chr(&HD) + strTime & vbNullChar
    frmDial.Icon = LoadPicture(App.Path + "\DialerOn.ico")
  Else
    nID.szTip = "Dialer: OFF" + Chr(&HD) + strTime & vbNullChar
    frmDial.Icon = LoadPicture(App.Path + "\DialerOff.ico")
  End If
  
  nID.hIcon = frmDial.Icon
  Shell_NotifyIcon NIM_MODIFY, nID
End Sub

Private Sub chkPhone_Click()
  If chkPhone.Value = 0 Then
    chkCard2.Value = 0
  End If
End Sub

Private Sub chkPhone_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
  If Button = 2 And Shift = 7 Then
    chkPhone.ToolTipText = strDial
  End If
End Sub

Private Sub cmdAdd_Click()
    Dim I As Integer
    Dim strTmp As String
    On Error Resume Next
    Select Case nFocusNo
        Case 1
            With comboCard1
                If Trim(.Text) = "" Then Exit Sub
                strTmp = .Text
                If .ListCount = 0 Then
                    .AddItem strTmp
                    Exit Sub
                End If
                For I = 0 To .ListCount - 1
                    .ListIndex = I
                    If .Text = strTmp Then Exit For
                Next I
                If I = .ListCount Then
                    .AddItem strTmp
                    .ListIndex = 0
                    Exit Sub
                End If
                .ListIndex = 0
            End With
        Case 2
            With comboAccount1
                strTmp = .Text
                If .ListCount = 0 Then
                    .AddItem strTmp
                    Exit Sub
                End If
                For I = 0 To .ListCount - 1
                    .ListIndex = I
                    If .Text = strTmp Then Exit For
                Next I
                If I = .ListCount Then
                    .AddItem strTmp
                    .ListIndex = 0
                    Exit Sub
                End If
                .ListIndex = 0
            End With
        Case 3
            With comboCard2
                If Trim(.Text) = "" Then Exit Sub
                strTmp = .Text
                If .ListCount = 0 Then
                    .AddItem strTmp
                    Exit Sub
                End If
                For I = 0 To .ListCount - 1
                    .ListIndex = I
                    If .Text = strTmp Then Exit For
                Next I
                If I = .ListCount Then
                    .AddItem strTmp
                    .ListIndex = 0
                    Exit Sub
                End If
                .ListIndex = 0
            End With
        Case 4
            With comboAccount2
                If Trim(.Text) = "" Then Exit Sub
                strTmp = .Text
                If .ListCount = 0 Then
                    .AddItem strTmp
                    Exit Sub
                End If
                For I = 0 To .ListCount - 1
                    .ListIndex = I
                    If .Text = strTmp Then Exit For
                Next I
                If I = .ListCount Then
                    .AddItem strTmp
                    .ListIndex = 0
                    Exit Sub
                End If
                .ListIndex = 0
            End With
        Case 5, 6
            AdodcDial.Recordset.AddNew
    End Select
End Sub

Private Sub cmdCount_Click()
    Dim strPhone As String
    On Error Resume Next
    
    With AdodcDial
        If .Recordset.RecordCount < 1 Or IsNull(.Recordset![Phone]) Then Exit Sub
        strPhone = .Recordset![Phone]
        .RecordSource = "select [Phone],count(*) AS [Rings] from CallIn " + _
                        "where [Phone]='" + strPhone + "' group by [Phone]"
        .Refresh
        MsgBox strPhone + " has called " + ts(.Recordset![Rings]) + " time(s).", vbInformation
        ShowGrid
    End With
End Sub

Private Sub cmdDel_Click()
  Dim nRet As Integer
  Dim strTitle As String
  Dim strPhone As String
  Dim strName As String
  On Error Resume Next
  
  Select Case nFocusNo
    Case 1
      With comboCard1
        If .Text = "" Then Exit Sub
        nRet = MsgBox("Are you sure?", vbQuestion + vbYesNo, "Card1")
        If nRet = 7 Then Exit Sub
        .RemoveItem .ListIndex
        If .ListCount > 0 Then .ListIndex = 0
      End With
    Case 2
      With comboAccount1
        nRet = MsgBox("Are you sure?", vbQuestion + vbYesNo, "Account1")
        If nRet = 7 Then Exit Sub
        .RemoveItem .ListIndex
        If .ListCount > 0 Then .ListIndex = 0
      End With
    Case 3
      With comboCard2
        If .Text = "" Then Exit Sub
        nRet = MsgBox("Are you sure?", vbQuestion + vbYesNo, "Card2")
        If nRet = 7 Then Exit Sub
        .RemoveItem .ListIndex
        If .ListCount > 0 Then .ListIndex = 0
      End With
    Case 4
      With comboAccount2
        nRet = MsgBox("Are you sure?", vbQuestion + vbYesNo, "Account2")
        If nRet = 7 Then Exit Sub
        .RemoveItem .ListIndex
        If .ListCount > 0 Then .ListIndex = 0
      End With
    Case 5, 6
      With AdodcDial.Recordset
        strTitle = GetNoString(AdodcDial.RecordSource, " ", 3) + " -- " + Trim(Str(![ID]))
        If chkPhone.Value = 1 Then strTitle = strTitle + "(Previous)"
        nRet = MsgBox("Are you sure?", vbQuestion + vbYesNo, strTitle)
        If nRet = 7 Then Exit Sub
        
        If chkPhone.Value = 0 Then
          .Delete
        Else
          strPhone = ![Phone]
          strName = ![Name]
          Do While Not .BOF
            .MovePrevious
            If strPhone = ![Phone] And strName = ![Name] Then .Delete
          Loop
        End If
          
        .Requery
        If nFocusNo = 5 Then
          .MoveFirst
        Else
          .MoveLast
        End If
      End With
  End Select
End Sub

Private Sub cmdDial_Click()
  Const nCardLength = 8   'ATDT110
  On Error Resume Next
  
  strDial = ""
  ChangeIcon ICON_OFF
  
  If chkCard1.Value = 1 And comboCard1.Text <> "" And comboCard1.Text <> "-" Then
    If comboAccount1.Text = "" Or comboAccount1.Text = "-" Then
      'For home use
      strDial = "ATS8=3DT" + comboCard1.Text     '17911-025-1234567
      chkCard2.Value = 0
    Else
      strDial = "ATS8=3DT" + comboCard1.Text + ",1," + comboAccount1.Text + "#," + _
                txtPassword1.Text + "#"
    End If
  End If
  
  If chkCard2.Value = 1 And comboCard2.Text <> "" And comboCard2.Text <> "-" Then
    If comboAccount2.Text = "" Or comboAccount2.Text = "-" Then
      strDial = strDial + "," + comboCard2.Text
    Else
      strDial = strDial + "," + comboCard2.Text + "#,1," + _
              comboAccount2.Text + "#," + txtPassword2.Text + "#"
    End If
  End If
  
  If chkPhone.Value = 1 And txtPhone.Text <> "" Then
    If InStr(1, strDial, "#") > 0 Then     'With Card
      If GetEndChar(strDial) = "#" Then
        strDial = strDial + "," + txtPhone.Text + "#"
      Else
        strDial = strDial + txtPhone.Text + "#"
      End If
    Else                                  'Without obvious Card
      If InStr(1, strDial, "ATS8=3DT", vbTextCompare) > 0 Then
        strDial = strDial + txtPhone.Text
      Else
        strDial = "ATS8=3DT" + txtPhone.Text
      End If
    End If
  End If
  
  If Len(Trim(strDial)) > nCardLength Then  'Add the End Mark
    strDial = strDial + ";" + Chr(13)
    
    CloseMsComm MSComm1, 50
    OpenMsComm MSComm1, 50
    
    shpSignal.FillColor = vbBlack
    nStatus = STATUS_DIAL
    MSComm1.Output = strDial
    
    t_Dial_Test.Interval = DIAL_STATUS_INTERVAL
    t_Dial_Test.Enabled = True
    
    tComm.Interval = COMMON_INTERVAL
  End If
End Sub

Public Sub cmdIn_Click()
  'ATI15
  'Display caller ID information from the current call (if in progress) or the last call (if between calls).
  'The caller ID information remains until either the modem is reset or until the modem receives another valid caller ID signal.
  
  'Using the #CID command, you can have the Courier 56K Business Modem
  'send the information to your computer between the first and second
  'RING messages. The Caller ID information is displayed only once.
  
  'AT#CID=1
  'Enable Caller ID with formatted output
  'AT#CID=3
  'Enable Caller ID with formatted output and name suppressed
  
  'An Example of Formatted Caller ID presentation:

  'RING

  'Date = 1015
  'Time = 2038
  'NMBR = 8475550001#
  'Name = U.S.Robotics

  'RING

    On Error Resume Next
    ChangeIcon ICON_OFF
    CloseMsComm MSComm1, 50
    nStatus = STATUS_IDLE
    shpSignal.FillColor = vbBlack
    StatusBar1.Panels(1).Text = "Idle"
    OpenMsComm MSComm1, 100
    MSComm1.Output = "ATS0=15#CID=1" + Chr(&HD)
    nStatus = STATUS_IN
    tComm.Interval = COMMON_INTERVAL    'Change at last.
End Sub

Public Sub cmdNow_Click()
    On Error Resume Next
    CloseMsComm MSComm1, 50
    OpenMsComm MSComm1, 50
    strDial = "ATH1" + Chr(&HD)  'off hook
    nStatus = STATUS_NOW
    ChangeIcon ICON_ON
    MSComm1.Output = strDial
    shpSignal.FillColor = vbBlue
    StatusBar1.Panels(1) = "Now..."
End Sub

Public Sub cmdReset_Click()
    On Error Resume Next
    If nGridShow = SHOW_CALLIN Then
        nGridShow = SHOW_PHONEBOOK
        ShowGrid
    End If
    shpSignal.FillColor = vbBlack
    If nStatus = STATUS_DIAL Or nStatus = STATUS_NOW Or nStatus = STATUS_IN Then
        nStatus = STATUS_IDLE
        ChangeIcon ICON_OFF
        StatusBar1.Panels(1).Text = "Idle"
        t_Dial_Test.Enabled = False
        CloseMsComm MSComm1, 50
        Exit Sub
    End If
    StatusBar1.Panels(1).Text = "Testing, please wait ..."
    nStatus = STATUS_TEST
    ChangeIcon ICON_ON
    nTestNo = 1
    t_Dial_Test.Interval = COMMON_INTERVAL
    t_Dial_Test.Enabled = True
    SetPortNoAndTest nTestNo
End Sub

Private Sub cmdSave_Click()
    Dim strFile As String
    Dim I As Integer
    Dim nRet As Integer
    On Error Resume Next
    nRet = MsgBox("Are you sure to overwrite?", vbQuestion + vbYesNo, "Save")
    If nRet = 7 Then Exit Sub
    '&Card1/Card2/&$Account1/Account2/$
    ''''''''''''''''''''''''''''For Card1'''''''''''''''''''''''''''''
    strFile = "&"
    With comboCard1
        For I = 0 To .ListCount - 1
            .ListIndex = I
            If .Text <> "" And .Text <> "-" Then strFile = strFile + .Text + "/"
        Next I
        strFile = strFile + "&"
        .ListIndex = 0
    End With
    
    strFile = strFile + "$"
    With comboAccount1
        For I = 0 To .ListCount - 1
            .ListIndex = I
            If .Text <> "" And .Text <> "-" Then strFile = strFile + .Text + "/"
        Next I
        strFile = strFile + "$"
        .ListIndex = 0
    End With
    
    WriteStringToTxt strFile, App.Path + "\Card1.txt"
    SaveSetting App.Title, "Value", "Pwd1", Trim(txtPassword1.Text)
    
    ''''''''''''''''''''''''''''For Card2'''''''''''''''''''''''''''''
    strFile = "&"
    With comboCard2
        For I = 0 To .ListCount - 1
            .ListIndex = I
            If .Text <> "" And .Text <> "-" Then strFile = strFile + .Text + "/"
        Next I
        strFile = strFile + "&"
        .ListIndex = 0
    End With
    strFile = strFile + "$"
    With comboAccount2
        For I = 0 To .ListCount - 1
            .ListIndex = I
            If .Text <> "" And .Text <> "-" Then strFile = strFile + .Text + "/"
        Next I
        strFile = strFile + "$"
        .ListIndex = 0
    End With
    WriteStringToTxt strFile, App.Path + "\Card2.txt"
    SaveSetting App.Title, "Value", "Pwd2", Trim(txtPassword2.Text)
    MsgBox "Save OK!", vbInformation + vbOKOnly, "Save"
End Sub

Private Sub comboAccount1_Click()
  If comboAccount1.Text = "" Or comboAccount1.Text = "-" Then
    chkCard2.Value = 0
  End If
End Sub

Private Sub comboCard1_Click()
  If Trim(comboCard1.Text) = "" Or comboCard1.Text = "-" Then
    chkCard1.Value = 0
    chkCard2.Value = 0
  Else
    chkCard1.Value = 1
  End If
End Sub

Private Sub comboCard1_GotFocus()
  nFocusNo = 1
End Sub

Private Sub comboAccount1_GotFocus()
  nFocusNo = 2
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -