home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / COMPTOOL / MSCOMM / FRMPROPS.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-16  |  12.0 KB  |  368 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.0#0"; "comctl32.ocx"
  3. Begin VB.Form frmProperties 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "CommPort Properties"
  6.    ClientHeight    =   4260
  7.    ClientLeft      =   4140
  8.    ClientTop       =   1665
  9.    ClientWidth     =   6015
  10.    Icon            =   "frmProps.frx":0000
  11.    LinkTopic       =   "Form3"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   4260
  16.    ScaleWidth      =   6015
  17.    ShowInTaskbar   =   0   'False
  18.    Begin VB.Frame fraSettings 
  19.       BorderStyle     =   0  'None
  20.       Height          =   3495
  21.       Left            =   255
  22.       TabIndex        =   1
  23.       Top             =   570
  24.       Width           =   5445
  25.       Begin VB.CommandButton cmdCancel 
  26.          Caption         =   "Cancel"
  27.          Height          =   300
  28.          Left            =   4335
  29.          TabIndex        =   22
  30.          Top             =   1065
  31.          Width           =   1080
  32.       End
  33.       Begin VB.Frame Frame1 
  34.          Caption         =   "Maximum Speed"
  35.          Height          =   870
  36.          Left            =   180
  37.          TabIndex        =   20
  38.          Top             =   630
  39.          Width           =   2340
  40.          Begin VB.ComboBox cboSpeed 
  41.             Height          =   315
  42.             Left            =   375
  43.             Style           =   2  'Dropdown List
  44.             TabIndex        =   21
  45.             Top             =   330
  46.             Width           =   1695
  47.          End
  48.       End
  49.       Begin VB.Frame fraConnection 
  50.          Caption         =   "Connection Preferences"
  51.          Height          =   1770
  52.          Left            =   180
  53.          TabIndex        =   12
  54.          Top             =   1635
  55.          Width           =   2325
  56.          Begin VB.ComboBox cboStopBits 
  57.             Height          =   315
  58.             Left            =   1050
  59.             Style           =   2  'Dropdown List
  60.             TabIndex        =   16
  61.             Top             =   1260
  62.             Width           =   1140
  63.          End
  64.          Begin VB.ComboBox cboParity 
  65.             Height          =   315
  66.             Left            =   1050
  67.             Style           =   2  'Dropdown List
  68.             TabIndex        =   15
  69.             Top             =   810
  70.             Width           =   1140
  71.          End
  72.          Begin VB.ComboBox cboDataBits 
  73.             Height          =   315
  74.             Left            =   1050
  75.             Style           =   2  'Dropdown List
  76.             TabIndex        =   14
  77.             Top             =   330
  78.             Width           =   1140
  79.          End
  80.          Begin VB.Label Label5 
  81.             Caption         =   "Stop Bits:"
  82.             Height          =   285
  83.             Left            =   180
  84.             TabIndex        =   19
  85.             Top             =   1320
  86.             Width           =   885
  87.          End
  88.          Begin VB.Label Label4 
  89.             Caption         =   "Parity:"
  90.             Height          =   285
  91.             Left            =   180
  92.             TabIndex        =   18
  93.             Top             =   855
  94.             Width           =   615
  95.          End
  96.          Begin VB.Label Label3 
  97.             Caption         =   "Data Bits:"
  98.             Height          =   285
  99.             Left            =   180
  100.             TabIndex        =   17
  101.             Top             =   375
  102.             Width           =   825
  103.          End
  104.       End
  105.       Begin VB.ComboBox cboPort 
  106.          Height          =   315
  107.          Left            =   900
  108.          Style           =   2  'Dropdown List
  109.          TabIndex        =   11
  110.          Top             =   150
  111.          Width           =   1425
  112.       End
  113.       Begin VB.CommandButton cmdOK 
  114.          Caption         =   "OK"
  115.          Default         =   -1  'True
  116.          Height          =   300
  117.          Left            =   4335
  118.          MaskColor       =   &H00000000&
  119.          TabIndex        =   10
  120.          Top             =   705
  121.          Width           =   1080
  122.       End
  123.       Begin VB.Frame Frame7 
  124.          Caption         =   "&Echo"
  125.          Height          =   870
  126.          Left            =   2595
  127.          TabIndex        =   7
  128.          Top             =   630
  129.          Width           =   1590
  130.          Begin VB.OptionButton optEcho 
  131.             Caption         =   "Off"
  132.             Height          =   315
  133.             Index           =   0
  134.             Left            =   135
  135.             MaskColor       =   &H00000000&
  136.             TabIndex        =   9
  137.             Top             =   360
  138.             Width           =   615
  139.          End
  140.          Begin VB.OptionButton optEcho 
  141.             Caption         =   "On"
  142.             Height          =   195
  143.             Index           =   1
  144.             Left            =   795
  145.             MaskColor       =   &H00000000&
  146.             TabIndex        =   8
  147.             Top             =   420
  148.             Width           =   555
  149.          End
  150.       End
  151.       Begin VB.Frame Frame5 
  152.          Caption         =   "&Flow Control"
  153.          Height          =   1770
  154.          Left            =   2595
  155.          TabIndex        =   2
  156.          Top             =   1635
  157.          Width           =   1620
  158.          Begin VB.OptionButton optFlow 
  159.             Caption         =   "None"
  160.             Height          =   255
  161.             Index           =   0
  162.             Left            =   180
  163.             MaskColor       =   &H00000000&
  164.             TabIndex        =   6
  165.             Top             =   345
  166.             Width           =   855
  167.          End
  168.          Begin VB.OptionButton optFlow 
  169.             Caption         =   "Xon/Xoff"
  170.             Height          =   255
  171.             Index           =   1
  172.             Left            =   180
  173.             MaskColor       =   &H00000000&
  174.             TabIndex        =   5
  175.             Top             =   645
  176.             Width           =   1095
  177.          End
  178.          Begin VB.OptionButton optFlow 
  179.             Caption         =   "RTS"
  180.             Height          =   255
  181.             Index           =   2
  182.             Left            =   180
  183.             MaskColor       =   &H00000000&
  184.             TabIndex        =   4
  185.             Top             =   945
  186.             Width           =   735
  187.          End
  188.          Begin VB.OptionButton optFlow 
  189.             Caption         =   "Xon/RTS"
  190.             Height          =   255
  191.             Index           =   3
  192.             Left            =   180
  193.             MaskColor       =   &H00000000&
  194.             TabIndex        =   3
  195.             Top             =   1245
  196.             Width           =   1155
  197.          End
  198.       End
  199.       Begin VB.Label Label1 
  200.          Caption         =   "Port:"
  201.          Height          =   315
  202.          Left            =   330
  203.          TabIndex        =   13
  204.          Top             =   180
  205.          Width           =   495
  206.       End
  207.    End
  208.    Begin ComctlLib.TabStrip tabSettings 
  209.       Height          =   4065
  210.       Left            =   90
  211.       TabIndex        =   0
  212.       Top             =   105
  213.       Width           =   5820
  214.       _ExtentX        =   10266
  215.       _ExtentY        =   7170
  216.       BeginProperty Tabs {0713E432-850A-101B-AFC0-4210102A8DA7} 
  217.          NumTabs         =   1
  218.          BeginProperty Tab1 {0713F341-850A-101B-AFC0-4210102A8DA7} 
  219.             Caption         =   "Properties"
  220.             ImageVarType    =   2
  221.          EndProperty
  222.       EndProperty
  223.    End
  224. Attribute VB_Name = "frmProperties"
  225. Attribute VB_Base = "0{7B2E0C91-D502-11CF-9BF3-00AA002FFD8F}"
  226. Attribute VB_GlobalNameSpace = False
  227. Attribute VB_Creatable = False
  228. Attribute VB_TemplateDerived = False
  229. Attribute VB_PredeclaredId = True
  230. Attribute VB_Exposed = False
  231. Private iFlow As Integer, iTempEcho As Boolean
  232. Sub LoadPropertySettings()
  233. Dim i As Integer, Settings As String, Offset As Integer
  234. ' Load Port Settings
  235. For i = 1 To 16
  236.     cboPort.AddItem "Com" & Trim$(Str$(i))
  237. Next i
  238. ' Load Speed Settings
  239. cboSpeed.AddItem "110"
  240. cboSpeed.AddItem "300"
  241. cboSpeed.AddItem "600"
  242. cboSpeed.AddItem "1200"
  243. cboSpeed.AddItem "2400"
  244. cboSpeed.AddItem "4800"
  245. cboSpeed.AddItem "9600"
  246. cboSpeed.AddItem "14400"
  247. cboSpeed.AddItem "19200"
  248. cboSpeed.AddItem "28800"
  249. cboSpeed.AddItem "38400"
  250. cboSpeed.AddItem "56000"
  251. cboSpeed.AddItem "57600"
  252. cboSpeed.AddItem "115200"
  253. cboSpeed.AddItem "128000"
  254. cboSpeed.AddItem "256000"
  255. ' Load Data Bit Settings
  256. cboDataBits.AddItem "4"
  257. cboDataBits.AddItem "5"
  258. cboDataBits.AddItem "6"
  259. cboDataBits.AddItem "7"
  260. cboDataBits.AddItem "8"
  261. ' Load Parity Settings
  262. cboParity.AddItem "Even"
  263. cboParity.AddItem "Odd"
  264. cboParity.AddItem "None"
  265. cboParity.AddItem "Mark"
  266. cboParity.AddItem "Space"
  267. ' Load Stop Bit Settings
  268. cboStopBits.AddItem "1"
  269. cboStopBits.AddItem "1.5"
  270. cboStopBits.AddItem "2"
  271. ' Set Default Settings
  272. Settings = frmTerminal.MSComm1.Settings
  273. ' In all cases the right most part of Settings will be 1 character
  274. ' except when there are 1.5 stop bits.
  275. If InStr(Settings, ".") > 0 Then
  276.     Offset = 2
  277.     Offset = 0
  278. End If
  279. cboSpeed.Text = Left$(Settings, Len(Settings) - 6 - Offset)
  280. Select Case Mid$(Settings, Len(Settings) - 4 - Offset, 1)
  281. Case "e"
  282.     cboParity.ListIndex = 0
  283. Case "m"
  284.     cboParity.ListIndex = 1
  285. Case "n"
  286.     cboParity.ListIndex = 2
  287. Case "o"
  288.     cboParity.ListIndex = 3
  289. Case "s"
  290.     cboParity.ListIndex = 4
  291. End Select
  292. cboDataBits.Text = Mid$(Settings, Len(Settings) - 2 - Offset, 1)
  293. cboStopBits.Text = Right$(Settings, 1 + Offset)
  294. cboPort.ListIndex = frmTerminal.MSComm1.CommPort - 1
  295. optFlow(frmTerminal.MSComm1.Handshaking).Value = True
  296. If Echo Then
  297.     optEcho(1).Value = True
  298.     optEcho(0).Value = True
  299. End If
  300. End Sub
  301. Private Sub cmdCancel_Click()
  302. Unload Me
  303. End Sub
  304. Private Sub cmdOK_Click()
  305. Dim OldPort As Integer, ReOpen As Boolean
  306. On Error Resume Next
  307. Echo = iTempEcho
  308. OldPort = frmTerminal.MSComm1.CommPort
  309. NewPort = cboPort.ListIndex + 1
  310. If NewPort <> OldPort Then                   ' If the port number changes, close the old port.
  311.     If frmTerminal.MSComm1.PortOpen Then
  312.            frmTerminal.MSComm1.PortOpen = False
  313.            ReOpen = True
  314.     End If
  315.     frmTerminal.MSComm1.CommPort = NewPort          ' Set the new port number.
  316.     If Err = 0 Then
  317.         If ReOpen Then
  318.             frmTerminal.MSComm1.PortOpen = True
  319.             frmTerminal.mnuOpen.Checked = frmTerminal.MSComm1.PortOpen
  320.             frmTerminal.mnuSendText.Enabled = frmTerminal.MSComm1.PortOpen
  321.             frmTerminal.tbrToolBar.Buttons("TransmitTextFile").Enabled = frmTerminal.MSComm1.PortOpen
  322.         End If
  323.     End If
  324.         
  325.     If Err Then
  326.         MsgBox Error$, 48
  327.         frmTerminal.MSComm1.CommPort = OldPort
  328.         Exit Sub
  329.     End If
  330. End If
  331. frmTerminal.MSComm1.Settings = Trim$(cboSpeed.Text) & "," & Left$(cboParity.Text, 1) _
  332.     & "," & Trim$(cboDataBits.Text) & "," & Trim$(cboStopBits.Text)
  333. If Err Then
  334.     MsgBox Error$, 48
  335.     Exit Sub
  336. End If
  337. frmTerminal.MSComm1.Handshaking = iFlow
  338. If Err Then
  339.     MsgBox Error$, 48
  340.     Exit Sub
  341. End If
  342. SaveSetting App.Title, "Properties", "Settings", frmTerminal.MSComm1.Settings
  343. SaveSetting App.Title, "Properties", "CommPort", frmTerminal.MSComm1.CommPort
  344. SaveSetting App.Title, "Properties", "Handshaking", frmTerminal.MSComm1.Handshaking
  345. SaveSetting App.Title, "Properties", "Echo", Echo
  346. Unload Me
  347. End Sub
  348. Private Sub Form_Load()
  349. ' Set the form's size
  350. Me.Left = (Screen.Width - Me.Width) / 2
  351. Me.Top = (Screen.Height - Me.Height) / 2
  352. ' Size the frame to fit in the tabstrip control
  353. fraSettings.Move tabSettings.ClientLeft, tabSettings.ClientTop
  354. ' Make sure the frame is the top most control
  355. fraSettings.ZOrder
  356. ' Load current property settings
  357. LoadPropertySettings
  358. End Sub
  359. Private Sub optEcho_Click(Index As Integer)
  360. If Index = 1 Then
  361.     iTempEcho = True
  362.     iTempEcho = False
  363. End If
  364. End Sub
  365. Private Sub optFlow_Click(Index As Integer)
  366. iFlow = Index
  367. End Sub
  368.