📄 formmain.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "mscomm32.ocx"
Begin VB.Form FormMain
Caption = "拨测程序"
ClientHeight = 4920
ClientLeft = 60
ClientTop = 345
ClientWidth = 3390
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4920
ScaleWidth = 3390
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 735
Left = 2400
TabIndex = 26
Top = 2280
Width = 855
End
Begin VB.CommandButton CommandRefreshCommPort
Caption = "刷新"
Height = 300
Left = 1800
TabIndex = 25
Top = 480
Width = 855
End
Begin VB.ComboBox ComboCommPort
Height = 300
Left = 720
Sorted = -1 'True
TabIndex = 24
Top = 480
Width = 975
End
Begin VB.Timer TimerBackTimer
Enabled = 0 'False
Interval = 1000
Left = 3000
Top = 360
End
Begin VB.CheckBox CheckONTOP
Caption = "ON TOP"
Height = 255
Left = 2520
TabIndex = 22
Top = 120
Width = 855
End
Begin VB.Frame FrameSmallKeyPad
Height = 2655
Left = 120
TabIndex = 9
Top = 2160
Width = 1935
Begin VB.CommandButton CommandDTMF0
Caption = "0"
Height = 495
Left = 720
TabIndex = 21
Top = 2040
Width = 495
End
Begin VB.CommandButton CommandDTMF1
Caption = "1"
Height = 495
Left = 120
TabIndex = 20
Top = 240
Width = 495
End
Begin VB.CommandButton CommandDTMF2
Caption = "2"
Height = 495
Left = 720
TabIndex = 19
Top = 240
Width = 495
End
Begin VB.CommandButton CommandDTMF3
Caption = "3"
Height = 495
Left = 1320
TabIndex = 18
Top = 240
Width = 495
End
Begin VB.CommandButton CommandDTMF4
Caption = "4"
Height = 495
Left = 120
TabIndex = 17
Top = 840
Width = 495
End
Begin VB.CommandButton CommandDTMF5
Caption = "5"
Height = 495
Left = 720
TabIndex = 16
Top = 840
Width = 495
End
Begin VB.CommandButton CommandDTMF6
Caption = "6"
Height = 495
Left = 1320
TabIndex = 15
Top = 840
Width = 495
End
Begin VB.CommandButton CommandDTMF7
Caption = "7"
Height = 495
Left = 120
TabIndex = 14
Top = 1440
Width = 495
End
Begin VB.CommandButton CommandDTMF8
Caption = "8"
Height = 495
Left = 720
TabIndex = 13
Top = 1440
Width = 495
End
Begin VB.CommandButton CommandDTMF9
Caption = "9"
Height = 495
Left = 1320
TabIndex = 12
Top = 1440
Width = 495
End
Begin VB.CommandButton CommandDTMFA
Caption = "*"
Height = 495
Left = 120
TabIndex = 11
Top = 2040
Width = 495
End
Begin VB.CommandButton CommandDTMFB
Caption = "#"
Height = 495
Left = 1320
TabIndex = 10
Top = 2040
Width = 495
End
End
Begin VB.CheckBox CheckSmallKEYPAD
Caption = "小键盘"
Height = 255
Left = 0
TabIndex = 8
Top = 1920
Width = 975
End
Begin VB.CommandButton CommandConnectMobile
Caption = "连接手机"
Height = 375
Left = 0
TabIndex = 5
Top = 840
Width = 1215
End
Begin VB.CommandButton CommandDialNumber
Caption = "测试"
Height = 975
Left = 1320
TabIndex = 4
Top = 840
Width = 855
End
Begin VB.Timer TimerDial
Enabled = 0 'False
Left = 3360
Top = 0
End
Begin MSCommLib.MSComm MSCommTimer
Left = 3360
Top = 120
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.TextBox TextTimer
Height = 270
Left = 1560
TabIndex = 2
Text = "15"
Top = 120
Width = 375
End
Begin VB.CheckBox CheckTimer
Caption = "指定时间间隔"
Height = 180
Left = 0
TabIndex = 1
Top = 120
Value = 1 'Checked
Width = 1455
End
Begin VB.TextBox TextDialedNumber
Height = 270
Left = 0
TabIndex = 0
Text = "10086"
Top = 1560
Width = 1215
End
Begin VB.Label LabelBackTimer
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "20"
BeginProperty Font
Name = "Arial"
Size = 26.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 2400
TabIndex = 23
Top = 960
Width = 570
End
Begin VB.Label LabelCommPort
AutoSize = -1 'True
Caption = "通信端口"
Height = 180
Left = 0
TabIndex = 7
Top = 480
Width = 720
End
Begin VB.Label LabelDialNumber
AutoSize = -1 'True
Caption = "被叫号码"
Height = 180
Left = 0
TabIndex = 6
Top = 1320
Width = 720
End
Begin VB.Label LabelSecond
AutoSize = -1 'True
Caption = "秒"
Height = 180
Left = 2040
TabIndex = 3
Top = 120
Width = 180
End
End
Attribute VB_Name = "FormMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOREDRAW = &H8
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOCOPYBITS = &H80
Private Const SWP_NOOWNERZORDER = &H200
Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Private Const HWND_TOP = 0
Private Const HWND_BOTTOM = 1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private mbOnTop As Boolean
Private Property Let OnTop(Setting As Boolean)
If Setting Then
SetWindowPos hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
SetWindowPos hwnd, -2, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
mbOnTop = Setting
End Property
Private Property Get OnTop() As Boolean
'Return the private variable set in Property Let
OnTop = mbOnTop
End Property
Private Sub CheckONTOP_Click()
OnTop = CheckONTOP.Value
End Sub
Private Sub CheckSmallKEYPAD_Click()
If CheckSmallKEYPAD.Value Then
FormMain.Height = 5325
Else
FormMain.Height = 2565
End If
End Sub
Private Sub CheckTimer_Click()
If CommandDialNumber.Caption = "测试" Then Exit Sub
If CheckTimer.Value Then
TimerDial.Interval = Int(TextTimer.Text) * 1000
LabelBackTimer.Caption = TextTimer.Text
TimerDial.Enabled = True
TimerBackTimer.Enabled = True
Else
LabelBackTimer.Caption = TextTimer.Text - LabelBackTimer.Caption
TimerDial.Enabled = False
End If
End Sub
Private Sub Command1_Click()
Dim inbuffer As String
inbuffer = String(1024, 0)
ReadFile MSCommTimer.CommID, inbuffer, 20, 1, 0
MsgBox inbuffer
End Sub
Private Sub CommandConnectMobile_Click()
On Error GoTo ExitSub
If CommandConnectMobile.Caption = "连接手机" Then
If Not MSCommTimer.PortOpen Then
MSCommTimer.CommPort = Right(ComboCommPort.Text, Len(ComboCommPort.Text) - 3)
MSCommTimer.Settings = "115200,N,8,1"
MSCommTimer.PortOpen = True
End If
CommandConnectMobile.Caption = "断开连接"
Else
If MSCommTimer.PortOpen Then
subHungUp
TimerBackTimer.Enabled = False
LabelBackTimer.Caption = 0
MSCommTimer.PortOpen = False
CommandConnectMobile.Caption = "连接手机"
End If
End If
Exit Sub
ExitSub:
MsgBox "连接手机失败,自己找原因去!"
End Sub
Private Sub CommandDialNumber_Click()
If MSCommTimer.PortOpen Then
TimerDial.Interval = 500
TimerDial.Enabled = True
TimerBackTimer.Enabled = True
Else
MsgBox "连接到手机先"
Exit Sub
End If
If CommandDialNumber.Caption = "测试" Then
CommandDialNumber.Caption = "结束"
Else
TimerBackTimer.Enabled = False
TimerDial.Enabled = False
LabelBackTimer.Caption = 0
subHungUp
CommandDialNumber.Caption = "测试"
End If
End Sub
Private Sub CommandDTMF0_Click()
subSendDTMF 0
End Sub
Private Sub CommandDTMF1_Click()
subSendDTMF 1
End Sub
Private Sub CommandDTMF2_Click()
subSendDTMF 2
End Sub
Private Sub CommandDTMF3_Click()
subSendDTMF 3
End Sub
Private Sub CommandDTMF4_Click()
subSendDTMF 4
End Sub
Private Sub CommandDTMF5_Click()
subSendDTMF 5
End Sub
Private Sub CommandDTMF6_Click()
subSendDTMF 6
End Sub
Private Sub CommandDTMF7_Click()
subSendDTMF 7
End Sub
Private Sub CommandDTMF8_Click()
subSendDTMF 8
End Sub
Private Sub CommandDTMF9_Click()
subSendDTMF 9
End Sub
Private Sub CommandDTMFA_Click()
subSendDTMF "*"
End Sub
Private Sub CommandDTMFB_Click()
subSendDTMF "#"
End Sub
Private Sub subRefreshCommPort()
Dim hKey As Long
Dim iCount As Long
Dim tsKeyValue As Long
Dim sKeyValue As String
Dim sKeyName As String
Dim lsKeyValue As Long
If RegOpenKey(HKEY_LOCAL_MACHINE, "Hardware\DeviceMap\SerialComm", hKey) <> 0 Then
MsgBox "打开注册表失败"
Exit Sub
End If
iCount = 0
ComboCommPort.Clear
Do
sKeyName = String$(255, 0)
sKeyValue = ""
tsKeyValue = 0
lsKeyValue = 0
If RegEnumValue(hKey, iCount, sKeyName, 255, 0, ByVal 0&, ByVal 0&, ByVal 0&) <> 0 Then Exit Do
sKeyName = Left$(sKeyName, lstrlen(sKeyName))
Call RegQueryValueEx(hKey, sKeyName, 0, tsKeyValue, vbNullString, lsKeyValue)
sKeyValue = String$(lsKeyValue, 0)
Call RegQueryValueEx(hKey, sKeyName, 0, tsKeyValue, ByVal sKeyValue, lsKeyValue)
sKeyValue = Left$(sKeyValue, lstrlen(sKeyValue))
'pritn the results to the combo
ComboCommPort.AddItem sKeyValue
iCount = iCount + 1
Loop
'Close the registry
RegCloseKey hKey
End Sub
Private Sub CommandRefreshCommPort_Click()
Dim sCommPortBeforeRefresh As String
sCommPortBeforeRefresh = ComboCommPort.Text
subRefreshCommPort
ComboCommPort.Text = sCommPortBeforeRefresh
End Sub
Private Sub Form_Load()
'FormMain.Height = 2640
LabelBackTimer.Caption = 0
subRefreshCommPort
ComboCommPort.Text = ComboCommPort.List(0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MSCommTimer.PortOpen Then
subHungUp
MSCommTimer.PortOpen = False
CommandConnectMobile.Caption = "连接手机"
End If
End Sub
Private Sub TextTimer_Change()
If TextTimer.Text = "" Then TextTimer.Text = 10
If Int(TextTimer.Text) > 60 Then TextTimer.Text = 60
End Sub
Private Sub TimerBackTimer_Timer()
If CheckTimer.Value Then
LabelBackTimer.Caption = Int(LabelBackTimer.Caption) - 1
Else
LabelBackTimer.Caption = Int(LabelBackTimer.Caption) + 1
End If
End Sub
Private Sub TimerDial_Timer()
TimerDial.Enabled = False
subHungUp
FormWait.Show 1
subDialNumber TextDialedNumber
If CheckTimer.Value Then
TimerDial.Interval = Int(TextTimer.Text) * 1000
LabelBackTimer.Caption = TextTimer.Text
TimerBackTimer.Enabled = False
TimerDial.Enabled = True
TimerBackTimer.Enabled = True
End If
End Sub
Private Sub subDialNumber(sDialedNumber As String)
If MSCommTimer.PortOpen = True Then
MSCommTimer.Output = "ATDT " & sDialedNumber & ";" & Chr(13)
Else
MsgBox "还没有连接到手机"
End If
End Sub
Private Sub subHungUp()
If MSCommTimer.PortOpen = True Then
MSCommTimer.Output = "AT+CHUP" & Chr(13)
Else
MsgBox "还没有连接到手机"
End If
End Sub
Private Sub subSendDTMF(sDTMFChar As String)
If MSCommTimer.PortOpen = True Then
MSCommTimer.Output = "AT+VTS=" & sDTMFChar & Chr(13)
Else
MsgBox "还没有连接到手机"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -