home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / commdemo / receive.txt < prev   
Text File  |  1991-07-11  |  3KB  |  147 lines

  1. Dim MinWindowSize As Integer
  2.  
  3. Sub Form_Load ()
  4.  
  5.     Height = Screen.Height / 2
  6.     Width = Screen.Width * .75
  7.     Top = Screen.Height * .25
  8.     Left = (Screen.Width - Width) / 2
  9.  
  10.     Receive_Text.Text = ""
  11.     Transmit_Text.Text = ""
  12.  
  13.     Initialize
  14.  
  15. End Sub
  16.  
  17. Sub Receive_Timer_Timer ()
  18.     
  19.     a$ = ReadCommPort(128)
  20.  
  21.     If Len(a$) > 0 Then
  22.         Receive_Text.selstart = Len(Receive_Text.Text) + 1
  23.         Receive_Text.sellength = 0
  24.         Receive_Text.seltext = a$
  25.     End If
  26.  
  27. End Sub
  28.  
  29. Sub Receive_Text_KeyPress (KeyAscii As Integer)
  30.  
  31.     KeyAscii = 0
  32.  
  33. End Sub
  34.  
  35. Sub Form_Unload (Cancel As Integer)
  36.  
  37.     If CommDemo.Menu_Windows.Enabled Then
  38.         CommDemo.Menu_Window_Receive_Transmit.Checked = FALSE
  39.         Hide
  40.         Cancel = TRUE
  41.         Exit Sub
  42.     End If
  43.  
  44. End Sub
  45.  
  46. Sub Transmit_Text_KeyPress (KeyAscii As Integer)
  47.  
  48.     If KeyAscii = 13 Then
  49.        If CommDemo.Menu_Comm_Send_CRLF.Checked = TRUE Then
  50.           Work$ = Chr$(13) + Chr$(11)
  51.        Else
  52.           Work$ = Chr$(13)
  53.        End If
  54.  
  55.        WriteCommPort Transmit_Text.Text + Work$
  56.        Transmit_Text.Text = ""
  57.        KeyAscii = 0
  58.     End If
  59.  
  60.     ' Remove the BEEP for CTRL characters
  61.  
  62.     If KeyAscii < 32 Then
  63.        KeyAscii = 0
  64.     End If
  65.  
  66. End Sub
  67.  
  68. Sub Initialize ()
  69.     
  70.     ForeColor = &HFFFFFF
  71.  
  72.     Text$ = "Receive Window"
  73.     FontSize = 10
  74.     
  75.     tHeight = TextHeight(Text$)
  76.     tWidth = TextWidth(Text$)
  77.  
  78.     CurrentX = (ScaleWidth - tWidth) \ 2
  79.     CurrentY = tHeight * .5
  80.     
  81.     Transmit_Text.Move 0, ScaleHeight - Transmit_Text.Height, ScaleWidth, Transmit_Text.Height
  82.     
  83.     Receive_Text.Top = tHeight * 2
  84.     MinWindowSize = Receive_Text.Top
  85.     Receive_Text.Move 0, Receive_Text.Top, ScaleWidth, ScaleHeight - (Transmit_Text.Height + Receive_Text.Top + tHeight * 2)
  86.     
  87.     Text$ = "Transmit Window"
  88.     FontSize = 10
  89.     
  90.     tHeight = TextHeight(Text$)
  91.     tWidth = TextWidth(Text$)
  92.  
  93.     CurrentX = (ScaleWidth - tWidth) \ 2
  94.     CurrentY = Transmit_Text.Top - tHeight * 1.5
  95.  
  96.     ForeColor = &H0
  97.  
  98.     MinWindowSize = MinWindowSize + (ScaleHeight - CurrentY) * 2
  99.  
  100. End Sub
  101.  
  102. Sub Form_Resize ()
  103.     
  104.     Work% = ScaleHeight - MinWindowSize
  105.  
  106.     If Work% < 0 Then
  107.         Height = Height + Abs(Work%)
  108.     End If
  109.  
  110.     Initialize
  111.  
  112. End Sub
  113.  
  114. Sub PaintText ()
  115.     
  116.     Cls
  117.         
  118.     ForeColor = &H0
  119.     Text$ = "Receive Window"
  120.     FontSize = 10
  121.     
  122.     tHeight = TextHeight(Text$)
  123.     tWidth = TextWidth(Text$)
  124.  
  125.     CurrentX = (ScaleWidth - tWidth) \ 2
  126.     CurrentY = tHeight * .5
  127.     Print Text$
  128.  
  129.     Text$ = "Transmit Window"
  130.     FontSize = 10
  131.     
  132.     tHeight = TextHeight(Text$)
  133.     tWidth = TextWidth(Text$)
  134.  
  135.     CurrentX = (ScaleWidth - tWidth) \ 2
  136.     CurrentY = Transmit_Text.Top - tHeight * 1.5
  137.     Print Text$
  138.  
  139. End Sub
  140.  
  141. Sub Form_Paint ()
  142.  
  143.     PaintText
  144.  
  145. End Sub
  146.  
  147.