home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / dos_win / winsock / packages / powertcp.exe / TELNET.FR_ / TELNET.bin (.txt)
Encoding:
Visual Basic Form  |  1995-02-16  |  8.5 KB  |  253 lines

  1. VERSION 2.00
  2. Begin Form frmTelnet 
  3.    BackColor       =   &H00000000&
  4.    Caption         =   "PowerTCP VT220"
  5.    ClientHeight    =   5820
  6.    ClientLeft      =   3132
  7.    ClientTop       =   2628
  8.    ClientWidth     =   7368
  9.    Height          =   6468
  10.    Icon            =   TELNET.FRX:0000
  11.    Left            =   3084
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5820
  14.    ScaleWidth      =   7368
  15.    Top             =   2028
  16.    Width           =   7464
  17.    Begin PowerTCP_TNT TNT1 
  18.       Flags           =   0
  19.       Left            =   600
  20.       LocalDotAddr    =   ""
  21.       OemLicense      =   ""
  22.       RemoteHost      =   ""
  23.       RemotePort      =   23
  24.       Top             =   1980
  25.    End
  26.    Begin PowerTCP_VT VT1 
  27.       Align           =   1  'Align Top
  28.       BackColor       =   &H00FFFFFF&
  29.       FontBold        =   0   'False
  30.       FontItalic      =   0   'False
  31.       FontName        =   "VT220_ascii"
  32.       FontSize        =   12
  33.       Height          =   1452
  34.       Left            =   0
  35.       OemLicense      =   ""
  36.       TabIndex        =   0
  37.       Top             =   0
  38.       Width           =   7368
  39.    End
  40.    Begin Menu mnuConnect 
  41.       Caption         =   "&Connect"
  42.       Begin Menu mnuCRemoteSystem 
  43.          Caption         =   "&Remote System..."
  44.       End
  45.       Begin Menu mnuCDisconnect 
  46.          Caption         =   "&Disconnect"
  47.          Enabled         =   0   'False
  48.       End
  49.       Begin Menu mnuCSep 
  50.          Caption         =   "-"
  51.       End
  52.       Begin Menu mnuCExit 
  53.          Caption         =   "E&xit"
  54.       End
  55.    End
  56.    Begin Menu mnuEdit 
  57.       Caption         =   "&Edit"
  58.       Begin Menu mnuECopy 
  59.          Caption         =   "&Copy"
  60.       End
  61.       Begin Menu mnuEPaste 
  62.          Caption         =   "&Paste"
  63.       End
  64.    End
  65.    Begin Menu mnuOptions 
  66.       Caption         =   "&Options"
  67.       Begin Menu mnuOLocalEcho 
  68.          Caption         =   "&Local Echo"
  69.       End
  70.    End
  71.    Begin Menu mnuHelp 
  72.       Caption         =   "&Help"
  73.       Begin Menu mnuHHowToUse 
  74.          Caption         =   "&How to Use Telnet"
  75.       End
  76.       Begin Menu mnuHSep 
  77.          Caption         =   "-"
  78.       End
  79.       Begin Menu mnuHAbout 
  80.          Caption         =   "&About Telnet..."
  81.       End
  82.    End
  83. ' IMPORTANT: We MUST use the API MessageBox function
  84. ' instead of the VB MsgBox function. See the PowerTCP
  85. ' README for more information.
  86. Declare Function MessageBox Lib "User" (ByVal hWnd As Integer, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Integer) As Integer
  87. Declare Sub ShellAbout Lib "SHELL.DLL" (ByVal hWnd As Integer, ByVal AppName As String, ByVal AppInfo As String, ByVal hIcon As Integer)
  88. ' Show parameters
  89. Const MODAL = 1
  90. Const MODELESS = 0
  91. ' MsgBox parameters
  92. Const MB_OK = 0                 ' OK button only
  93. Sub CenterForm (frmParent As Form, frmChild As Form)
  94. ' This procedure centers a form over another form.
  95. ' Calling this routine loads the dialog. Use the Show method
  96. ' to display the dialog after calling this routine ( ie MyFrm.Show 1)
  97. Dim l, t
  98.   ' get left offset
  99.   l = frmParent.Left + ((frmParent.Width - frmChild.Width) / 2)
  100.   If (l + frmChild.Width > screen.Width) Then
  101.     l = screen.Width = frmChild.Width
  102.   End If
  103.   ' get top offset
  104.   t = frmParent.Top + ((frmParent.Height - frmChild.Height) / 2)
  105.   If (t + frmChild.Height > screen.Height) Then
  106.     t = screen.Height - frmChild.Height
  107.   End If
  108.   ' center the child formfv
  109.   frmChild.Move l, t
  110. End Sub
  111. Sub Form_Load ()
  112.     VT1.Enabled = True
  113. End Sub
  114. Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  115.     mnuCExit_Click
  116. End Sub
  117. Sub Form_Resize ()
  118.     VT1.Height = ScaleHeight + screen.TwipsPerPixelX
  119. End Sub
  120. Sub Form_Unload (Cancel As Integer)
  121.     End
  122. End Sub
  123. Sub mnuCDisconnect_Click ()
  124.     Me.Caption = "PowerTCP VT220"
  125.     TNT1.Action = CLOSECOMM
  126. End Sub
  127. Sub mnuCExit_Click ()
  128.     ' Disconnect, and do a DoEvents for the connection
  129.     ' to finish closing (it will not close instantaneously).
  130.     TNT1.Action = CLOSECOMM
  131.     DoEvents
  132.     End
  133. End Sub
  134. Sub mnuCRemoteSystem_Click ()
  135.     CenterForm frmTelnet, frmConnect
  136.     frmConnect.Show MODAL
  137. End Sub
  138. Sub mnuECopy_Click ()
  139.     ' Copy selected text to Clipboard.
  140.     ClipBoard.Clear
  141.     ClipBoard.SetText Mid$(VT1.Text, VT1.SelStart, VT1.SelLength)
  142. End Sub
  143. Sub mnuEPaste_Click ()
  144.     ' Place text from Clipboard into VT1.
  145.     TNT1.Send = ClipBoard.GetText()
  146. End Sub
  147. Sub mnuHAbout_Click ()
  148.     ShellAbout 0, App.Title, "Version 1.0" & Chr$(10) & "Copyright 
  149.  1994 Dart Communications", Me.Icon
  150. End Sub
  151. Sub mnuHHowToUse_Click ()
  152.     Msg$ = "This application will connect to another"
  153.     Msg$ = Msg$ + " computer using the TELNET protocol."
  154.     Msg$ = Msg$ + "  This application is a Telnet"
  155.     Msg$ = Msg$ + " client."
  156.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Telnet: Page 1/4", 0)
  157.     Msg$ = "To connect to a Telnet host, choose"
  158.     Msg$ = Msg$ + " Connect... from the File menu. Enter"
  159.     Msg$ = Msg$ + " the name of the remote computer and"
  160.     Msg$ = Msg$ + " select a default port or type a port"
  161.     Msg$ = Msg$ + " number, and click OK. The default port"
  162.     Msg$ = Msg$ + " is telnet, number 23."
  163.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Telnet: Page 2/4", 0)
  164.     Msg$ = "Once you are connected,"
  165.     Msg$ = Msg$ + " any text you type or paste into the"
  166.     Msg$ = Msg$ + " text area is sent to the remote"
  167.     Msg$ = Msg$ + " host. All text received from the"
  168.     Msg$ = Msg$ + " host is displayed in the text area."
  169.     Msg$ = Msg$ + Chr$(10) & Chr$(10) & "To disconnect"
  170.     Msg$ = Msg$ + " from the host, choose Disconnect"
  171.     Msg$ = Msg$ + " from the File menu."
  172.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Telnet: Page 3/4", 0)
  173.     Msg$ = "Technical note: This"
  174.     Msg$ = Msg$ + " client program uses Dart's VT-220"
  175.     Msg$ = Msg$ + " custom control to emulate a VT-220"
  176.     Msg$ = Msg$ + ". This control can be licensed and used by"
  177.     Msg$ = Msg$ + " others to build emulation packages."
  178.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Telnet: Page 4/4", 0)
  179. End Sub
  180. Sub mnuOLocalEcho_Click ()
  181.     mnuOLocalEcho.Checked = Not (mnuOLocalEcho.Checked)
  182. End Sub
  183. Sub TNT1_Cmd (Cmd As Integer, TelnetOption As Integer, SubOption As String)
  184.     Dim MySubOption As String * 6
  185.     Select Case Cmd
  186.     Case SB_CMD
  187.         ' negotiate TermType suboption
  188.         If TelnetOption = 24 Then
  189.             MySubOption = Chr$(0) & "vt220"
  190.             i = Len(MySubOption)
  191.             TNT1.SubOption = MySubOption
  192.             TNT1.DoSubOption = 24
  193.         ElseIf TelnetOption = WINDOW_SIZE Then
  194.             Dim Columns As Integer
  195.             SubOpt = Chr$(0) & Chr$(80) & Chr$(0) & Chr$(24)
  196.             TNT1.SubOption = SubOpt
  197.             TNT1.DoSubOption = WINDOW_SIZE
  198.         End If
  199.     Case DO_CMD
  200.         If TelnetOption = 24 Then
  201.             ' want to subnegotiate TermType
  202.             TNT1.WillOption = 24
  203.         ElseIf TelnetOption = WINDOW_SIZE Then
  204.             TNT1.WillOption = WINDOW_SIZE
  205.         Else
  206.             TNT1.WontOption = TelnetOption
  207.         End If
  208.     Case DONT_CMD
  209.         If TelnetOption <> 1 Then
  210.             TNT1.WontOption = TelnetOption
  211.         End If
  212.         
  213.     Case WILL_CMD
  214.         If TelnetOption = 3 Then
  215.             ' do suppress go-aheads
  216.             TNT1.DoOption = 3
  217.         ElseIf TelnetOption = 1 Then
  218.             ' do echo characters sent
  219.             TNT1.DoOption = 1
  220.         Else
  221.             TNT1.DontOption = TelnetOption
  222.         End If
  223.     Case WONT_CMD
  224.         TNT1.DontOption = TelnetOption
  225.     End Select
  226. End Sub
  227. Sub TNT1_Connect ()
  228.     mnuCRemoteSystem.Enabled = False
  229.     mnuCDisconnect.Enabled = True
  230.     Me.Caption = "PowerTCP VT220 - " & Format$(TNT1.RemoteHost)
  231. End Sub
  232. Sub TNT1_Recv (RecvData As String)
  233.     If Len(RecvData) = 0 Then
  234.         mnuCRemoteSystem.Enabled = True
  235.         mnuCDisconnect.Enabled = False
  236.     Else
  237.         ' Place the received characters into the VT-220 emulator
  238.         VT1.Display = RecvData
  239.     End If
  240. End Sub
  241. Sub VT1_KeyPress (KeyString As String)
  242.     ' Make sure the user is connected, or else don't
  243.     ' display the character
  244.     If TNT1.State <> CONNECTED Then
  245.         Exit Sub
  246.     End If
  247.     ' Send the character to the host
  248.     TNT1.Send = KeyString
  249.     ' If the LocalEcho menu option is checked, then
  250.     ' we should display it locally as well.
  251.     If mnuOLocalEcho.Checked = True Then VT1.Display = KeyString
  252. End Sub
  253.