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

📄 commcfg.frm

📁 主要对win2000传真猫的监测
💻 FRM
字号:
VERSION 4.00
Begin VB.Form Commcfg 
   Caption         =   "CommDemo Configuration"
   ClientHeight    =   2715
   ClientLeft      =   1515
   ClientTop       =   1920
   ClientWidth     =   4905
   BeginProperty Font 
      name            =   "MS Sans Serif"
      charset         =   0
      weight          =   700
      size            =   8.25
      underline       =   0   'False
      italic          =   0   'False
      strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H80000008&
   Height          =   3120
   Left            =   1455
   LinkMode        =   1  'Source
   LinkTopic       =   "Form1"
   ScaleHeight     =   2715
   ScaleWidth      =   4905
   Top             =   1575
   Width           =   5025
   Begin VB.CommandButton CmdOk 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Ok"
      Height          =   495
      Left            =   3960
      TabIndex        =   5
      Top             =   360
      Width           =   735
   End
   Begin VB.Frame Frame2 
      Caption         =   "Speed"
      Height          =   2295
      Left            =   2040
      TabIndex        =   3
      Top             =   180
      Width           =   1695
      Begin VB.OptionButton OptionBaud 
         Caption         =   "56000 Baud"
         Height          =   255
         Index           =   5
         Left            =   120
         TabIndex        =   10
         Top             =   1860
         Value           =   -1  'True
         Width           =   1455
      End
      Begin VB.OptionButton OptionBaud 
         Caption         =   "28800 Baud"
         Height          =   255
         Index           =   4
         Left            =   120
         TabIndex        =   9
         Top             =   1560
         Width           =   1455
      End
      Begin VB.OptionButton OptionBaud 
         Caption         =   "14400 Baud"
         Height          =   255
         Index           =   3
         Left            =   120
         TabIndex        =   8
         Top             =   1260
         Width           =   1455
      End
      Begin VB.OptionButton OptionBaud 
         Caption         =   "9600 Baud"
         Height          =   255
         Index           =   2
         Left            =   120
         TabIndex        =   7
         Top             =   960
         Width           =   1455
      End
      Begin VB.OptionButton OptionBaud 
         Caption         =   "2400 Baud"
         Height          =   255
         Index           =   1
         Left            =   120
         TabIndex        =   6
         Top             =   660
         Width           =   1455
      End
      Begin VB.OptionButton OptionBaud 
         Caption         =   "1200 Baud"
         Height          =   255
         Index           =   0
         Left            =   120
         TabIndex        =   4
         Top             =   360
         Width           =   1455
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Device"
      Height          =   1095
      Left            =   240
      TabIndex        =   0
      Top             =   180
      Width           =   1335
      Begin VB.OptionButton OptionCom2 
         Caption         =   "COM2"
         Height          =   255
         Left            =   120
         TabIndex        =   2
         Top             =   720
         Width           =   975
      End
      Begin VB.OptionButton OptionCom1 
         Caption         =   "COM1"
         Height          =   255
         Left            =   120
         TabIndex        =   1
         Top             =   360
         Value           =   -1  'True
         Width           =   975
      End
   End
End
Attribute VB_Name = "Commcfg"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Private CurrentBaudSetting&
' The port to use and configuration may have changed
'
Private Sub CmdOk_Click()
    Dim baudtouse&
    Dim DeviceName$
    ' A more general array approach would also be
    ' easy to implement
    Select Case CurrentBaudSetting
        Case 0
            baudtouse = 1200
        Case 1
            baudtouse = 2400
        Case 2
            baudtouse = 9600
        Case 3
            baudtouse = 14400
        Case 4
            baudtouse = 28800
        Case 5
            baudtouse = 56000
    End Select

    ' An approach similar to the baud rate one with indexed
    ' option buttons would be better if you wanted to support
    ' 4 or more comm ports
    If OptionCom1.Value Then DeviceName = "COM1" Else DeviceName = "COM2"

    If Not (Comm Is Nothing) Then
        ' Comm is already valid. Have we changed ports?
        If DeviceName <> Comm.DeviceName Then
            ' We're changing device
            ' Note that this also serves to close and
            ' release the previous comm object
            Set Comm = New dwComm
            ' This demo doesn't use buffer sizes
            Call Comm.OpenComm(DeviceName, CommDemo)
        End If
        ' If device is unchanged, SetCommState is all that is needed
    Else
        Set Comm = New dwComm
        Call Comm.OpenComm(DeviceName, CommDemo)
    End If
    
    Comm.DCB.BaudRate = baudtouse
    Comm.DCB.fNull = True
    Comm.DCB.fErrorChar = True
    Comm.DCB.ErrorChar = "~"
    ' Perform any other DCB setting here
    ' Now record the configuration changes
    Call Comm.SetCommState
    Unload Me

End Sub

Private Sub Form_Load()
    If Comm Is Nothing Then
        CurrentBaudSetting = 5
    Else
        Select Case (Comm.DCB.BaudRate)
            Case 1200
                    CurrentBaudSetting = 0
            Case 2400
                    CurrentBaudSetting = 1
            Case 9600
                    CurrentBaudSetting = 2
            Case 14400
                    CurrentBaudSetting = 3
            Case 28800
                    CurrentBaudSetting = 4
            Case 56000
                    CurrentBaudSetting = 5
            Case Else
                    CurrentBaudSetting = 5
        End Select
    End If
    ' Set option button to current device
    OptionBaud(CurrentBaudSetting).Value = True

End Sub

Private Sub OptionBaud_Click(Index As Integer)
    CurrentBaudSetting = Index
End Sub

⌨️ 快捷键说明

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