home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / commdemo / global.bas < prev    next >
BASIC Source File  |  1991-07-11  |  4KB  |  109 lines

  1.  
  2. ' Communication Demo is a sample aplication showing how the
  3. ' Windows COMM API function can be used in a Visual Basic program.
  4. ' This sample program does not utilize all the functions available
  5. ' through the Windows COMM API function, but is a can be used as
  6. ' a starting point.                                                ==
  7.  
  8. Type CommStateDCB
  9.     Id          As String * 1   ' Port Id from OpenComm
  10.     BaudRate    As Integer      ' Baud Rate
  11.     ByteSize    As String * 1   ' Data Bit Size (4 to 8)
  12.     Parity      As String * 1   ' Parity
  13.     StopBits    As String * 1   ' Stop Bits
  14.     RlsTimeOut  As Integer      ' Carrier Detect Time "CD"
  15.     CtsTimeOut  As Integer      ' Clear-to-Send Time
  16.     DsrTimeOut  As Integer      ' Data-Set-Ready Time
  17.     ModeControl As Integer      ' Mode Control Bit Fields
  18.     XonChar     As String * 1   ' XON character
  19.     XoffChar    As String * 1   ' XOFF character
  20.     XonLim      As Integer      ' Min characters in buffer before XON is sent
  21.     XoffLim     As Integer      ' Max characters in buffer before XOFF is send
  22.     PeChar      As String * 1   ' Parity Error Character
  23.     EofChar     As String * 1   ' EOF/EOD character
  24.     EvtChar     As String * 1   ' Event character
  25.     TxDelay     As Integer      ' Reserved/Not Used
  26. End Type
  27.  
  28. Type TextMetrics
  29.     tmHeight As Integer
  30.     work1 As String * 14
  31.     work2 As String * 9
  32.     Work3 As String * 6
  33. End Type
  34.  
  35. Declare Function OpenComm Lib "user" (ByVal a As String, ByVal b As Integer, ByVal c As Integer) As Integer
  36. Declare Function CloseComm Lib "user" (ByVal a As Integer) As Integer
  37.  
  38. Declare Function WriteComm Lib "user" (ByVal a As Integer, ByVal b As String, ByVal c As Integer) As Integer
  39. Declare Function ReadComm Lib "user" (ByVal a As Integer, ByVal b As String, ByVal c As Integer) As Integer
  40.  
  41. Declare Function GetCommEventMask Lib "user" (ByVal a As Integer, ByVal b As Integer) As Integer
  42. Declare Function SetCommEventMask Lib "user" (ByVal a As Integer, ByVal b As Integer) As Integer
  43.  
  44. Declare Function SetCommState Lib "user" (b As CommStateDCB) As Integer
  45. Declare Function GetCommState Lib "user" (ByVal a As Integer, b As CommStateDCB) As Integer
  46.  
  47. Declare Function RemoveMenu Lib "User" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer
  48. Declare Function GetSystemMenu Lib "User" (ByVal hWnd As Integer, ByVal Action As Integer) As Integer
  49.  
  50. Global Const FALSE = 0
  51. Global Const TRUE = Not FALSE
  52.  
  53. Global Const MF_BYPOSITION = &H400  'Used by RemoveMenu()
  54.  
  55. ' COMM OPEN Error Numbers
  56.  
  57. Global Const IE_BADID = -1      ' Invalid or unsupported id
  58. Global Const IE_OPEN = -2       ' Device Already Open
  59. Global Const IE_NOPEN = -3      ' Device Not Open
  60. Global Const IE_MEMORY = -4     ' Unable to allocate queues
  61. Global Const IE_DEFAULT = -5    ' Error in default parameters
  62. Global Const IE_HARDWARE = -10  ' Hardware Not Present
  63. Global Const IE_BYTESIZE = -11  ' Illegal Byte Size
  64. Global Const IE_BAUDRATE = -12  ' Unsupported BaudRate
  65.  
  66. ' COMM EVENT MASK
  67.  
  68. Global Const EV_RXCHAR = &H1
  69. Global Const EV_RXFLAG = &H2
  70. Global Const EV_TXEMPTY = &H4
  71. Global Const EV_CTS = &H8
  72. Global Const EV_DSR = &H10
  73. Global Const EV_RLSD = &H20
  74. Global Const EV_BREAK = &H40
  75. Global Const EV_ERR = &H80
  76. Global Const EV_RING = &H100
  77. Global Const EV_PERR = &H200
  78. Global Const EV_ALL = &H3FF
  79.             
  80. Global CommHandle As Integer
  81. Global CommDeviceNum As Integer
  82.  
  83. Global CommPortName As String
  84. Global PostPortName As String
  85.  
  86. Global CommEventMask As Integer
  87. Global PostEventMask As Integer
  88.  
  89. Global CommState As CommStateDCB
  90. Global PostState As CommStateDCB
  91.  
  92. Global CommRBBuffer As Integer
  93. Global PostRBBuffer As Integer
  94.  
  95. Global CommTBBuffer As Integer
  96. Global PostTBBuffer As Integer
  97.  
  98. Global CommReadInterval As Integer
  99. Global PostReadInterval As Integer
  100.  
  101. Global CaptionLeft      As Integer
  102. Global CaptionTop       As Integer
  103. Global CaptionHeight    As Integer
  104. Global CaptionCenter    As Integer
  105. Global CaptionWidth     As Integer
  106. Global CaptionText$
  107.  
  108.  
  109.