home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / oocs / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-06  |  16.0 KB  |  476 lines

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Begin VB.Form frmCLient 
  4.    BorderStyle     =   4  'Fixed ToolWindow
  5.    Caption         =   "Client"
  6.    ClientHeight    =   2895
  7.    ClientLeft      =   1560
  8.    ClientTop       =   1710
  9.    ClientWidth     =   7230
  10.    Icon            =   "Form1.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   2895
  15.    ScaleWidth      =   7230
  16.    ShowInTaskbar   =   0   'False
  17.    Begin VB.CommandButton cmdRetract 
  18.       Caption         =   "&Retract"
  19.       Height          =   375
  20.       Left            =   6120
  21.       TabIndex        =   7
  22.       Top             =   4920
  23.       Width           =   975
  24.    End
  25.    Begin VB.TextBox Text1 
  26.       Height          =   1815
  27.       Left            =   120
  28.       MultiLine       =   -1  'True
  29.       ScrollBars      =   2  'Vertical
  30.       TabIndex        =   6
  31.       Top             =   3000
  32.       Width           =   6975
  33.    End
  34.    Begin VB.CommandButton cmdExit 
  35.       Caption         =   "E&xit"
  36.       Height          =   375
  37.       Left            =   6120
  38.       TabIndex        =   5
  39.       Top             =   2400
  40.       Width           =   975
  41.    End
  42.    Begin VB.Frame Frame1 
  43.       Caption         =   "Tasks"
  44.       Height          =   2295
  45.       Left            =   120
  46.       TabIndex        =   0
  47.       Top             =   0
  48.       Width           =   6975
  49.       Begin VB.PictureBox Picture1 
  50.          Height          =   1935
  51.          Left            =   1920
  52.          ScaleHeight     =   1875
  53.          ScaleWidth      =   4875
  54.          TabIndex        =   11
  55.          Top             =   240
  56.          Visible         =   0   'False
  57.          Width           =   4935
  58.          Begin VB.CommandButton cmdHide 
  59.             Caption         =   "&Hide"
  60.             Height          =   375
  61.             Left            =   3840
  62.             TabIndex        =   30
  63.             Top             =   1440
  64.             Width           =   855
  65.          End
  66.          Begin VB.Label Label 
  67.             BorderStyle     =   1  'Fixed Single
  68.             Height          =   255
  69.             Index           =   8
  70.             Left            =   3360
  71.             TabIndex        =   29
  72.             Top             =   1080
  73.             Width           =   1335
  74.          End
  75.          Begin VB.Label Label 
  76.             BorderStyle     =   1  'Fixed Single
  77.             Height          =   255
  78.             Index           =   7
  79.             Left            =   3600
  80.             TabIndex        =   28
  81.             Top             =   600
  82.             Width           =   1095
  83.          End
  84.          Begin VB.Label Label 
  85.             BorderStyle     =   1  'Fixed Single
  86.             Height          =   255
  87.             Index           =   6
  88.             Left            =   3480
  89.             TabIndex        =   27
  90.             Top             =   120
  91.             Width           =   1215
  92.          End
  93.          Begin VB.Label Label 
  94.             BorderStyle     =   1  'Fixed Single
  95.             Height          =   255
  96.             Index           =   5
  97.             Left            =   1200
  98.             TabIndex        =   26
  99.             Top             =   1560
  100.             Width           =   1455
  101.          End
  102.          Begin VB.Label Label 
  103.             BorderStyle     =   1  'Fixed Single
  104.             Height          =   255
  105.             Index           =   4
  106.             Left            =   1200
  107.             TabIndex        =   25
  108.             Top             =   1320
  109.             Width           =   1455
  110.          End
  111.          Begin VB.Label Label 
  112.             BorderStyle     =   1  'Fixed Single
  113.             Height          =   255
  114.             Index           =   3
  115.             Left            =   1200
  116.             TabIndex        =   24
  117.             Top             =   1080
  118.             Width           =   1455
  119.          End
  120.          Begin VB.Label Label 
  121.             BorderStyle     =   1  'Fixed Single
  122.             Height          =   255
  123.             Index           =   2
  124.             Left            =   1200
  125.             TabIndex        =   23
  126.             Top             =   840
  127.             Width           =   1455
  128.          End
  129.          Begin VB.Label Label 
  130.             BorderStyle     =   1  'Fixed Single
  131.             Height          =   255
  132.             Index           =   1
  133.             Left            =   1200
  134.             TabIndex        =   22
  135.             Top             =   360
  136.             Width           =   1455
  137.          End
  138.          Begin VB.Label Label 
  139.             BorderStyle     =   1  'Fixed Single
  140.             Height          =   255
  141.             Index           =   0
  142.             Left            =   1200
  143.             TabIndex        =   21
  144.             Top             =   120
  145.             Width           =   1455
  146.          End
  147.          Begin VB.Label LabelCap 
  148.             AutoSize        =   -1  'True
  149.             BackStyle       =   0  'Transparent
  150.             Caption         =   "Total RAM"
  151.             Height          =   195
  152.             Index           =   8
  153.             Left            =   120
  154.             TabIndex        =   20
  155.             Top             =   1080
  156.             Width           =   765
  157.          End
  158.          Begin VB.Label LabelCap 
  159.             AutoSize        =   -1  'True
  160.             BackStyle       =   0  'Transparent
  161.             Caption         =   "Memory Load"
  162.             Height          =   195
  163.             Index           =   7
  164.             Left            =   120
  165.             TabIndex        =   19
  166.             Top             =   840
  167.             Width           =   960
  168.          End
  169.          Begin VB.Label LabelCap 
  170.             BackStyle       =   0  'Transparent
  171.             Caption         =   "Available Virtual Ram"
  172.             Height          =   555
  173.             Index           =   6
  174.             Left            =   2760
  175.             TabIndex        =   18
  176.             Top             =   840
  177.             Width           =   780
  178.          End
  179.          Begin VB.Label LabelCap 
  180.             AutoSize        =   -1  'True
  181.             BackStyle       =   0  'Transparent
  182.             Caption         =   "Virtual Ram"
  183.             Height          =   195
  184.             Index           =   5
  185.             Left            =   2760
  186.             TabIndex        =   17
  187.             Top             =   600
  188.             Width           =   810
  189.          End
  190.          Begin VB.Label LabelCap 
  191.             BackStyle       =   0  'Transparent
  192.             Caption         =   "Available PageFile"
  193.             Height          =   435
  194.             Index           =   4
  195.             Left            =   2760
  196.             TabIndex        =   16
  197.             Top             =   120
  198.             Width           =   825
  199.          End
  200.          Begin VB.Label LabelCap 
  201.             AutoSize        =   -1  'True
  202.             BackStyle       =   0  'Transparent
  203.             Caption         =   "PageFile"
  204.             Height          =   195
  205.             Index           =   3
  206.             Left            =   120
  207.             TabIndex        =   15
  208.             Top             =   1560
  209.             Width           =   615
  210.          End
  211.          Begin VB.Label LabelCap 
  212.             AutoSize        =   -1  'True
  213.             BackStyle       =   0  'Transparent
  214.             Caption         =   "Avaliable RAM"
  215.             Height          =   195
  216.             Index           =   2
  217.             Left            =   120
  218.             TabIndex        =   14
  219.             Top             =   1320
  220.             Width           =   1050
  221.          End
  222.          Begin VB.Label LabelCap 
  223.             AutoSize        =   -1  'True
  224.             BackStyle       =   0  'Transparent
  225.             Caption         =   "Sys Directory:"
  226.             Height          =   195
  227.             Index           =   1
  228.             Left            =   120
  229.             TabIndex        =   13
  230.             Top             =   360
  231.             Width           =   975
  232.          End
  233.          Begin VB.Label LabelCap 
  234.             AutoSize        =   -1  'True
  235.             BackStyle       =   0  'Transparent
  236.             Caption         =   "Win Directory:"
  237.             Height          =   195
  238.             Index           =   0
  239.             Left            =   120
  240.             TabIndex        =   12
  241.             Top             =   120
  242.             Width           =   1005
  243.          End
  244.       End
  245.       Begin VB.ListBox List1 
  246.          Height          =   1620
  247.          Left            =   2040
  248.          TabIndex        =   4
  249.          Top             =   480
  250.          Width           =   4815
  251.       End
  252.       Begin VB.CommandButton cmdSysInfo 
  253.          Caption         =   "Retrieve Sys Info"
  254.          Enabled         =   0   'False
  255.          Height          =   375
  256.          Left            =   240
  257.          TabIndex        =   3
  258.          Top             =   1320
  259.          Width           =   1575
  260.       End
  261.       Begin VB.CommandButton cmdRetrieve 
  262.          Caption         =   "Retrieve File Paths"
  263.          Enabled         =   0   'False
  264.          Height          =   375
  265.          Left            =   240
  266.          TabIndex        =   2
  267.          Top             =   840
  268.          Width           =   1575
  269.       End
  270.       Begin VB.CommandButton cmdMsg 
  271.          Caption         =   "Custom Message"
  272.          Enabled         =   0   'False
  273.          Height          =   375
  274.          Left            =   240
  275.          TabIndex        =   1
  276.          Top             =   360
  277.          Width           =   1575
  278.       End
  279.       Begin VB.Label lblFileCnt 
  280.          AutoSize        =   -1  'True
  281.          Caption         =   "Total Files:"
  282.          Height          =   195
  283.          Left            =   4200
  284.          TabIndex        =   10
  285.          Top             =   240
  286.          Visible         =   0   'False
  287.          Width           =   765
  288.       End
  289.       Begin VB.Label lblCap 
  290.          AutoSize        =   -1  'True
  291.          Caption         =   "File Paths:"
  292.          Enabled         =   0   'False
  293.          Height          =   195
  294.          Left            =   2040
  295.          TabIndex        =   9
  296.          Top             =   240
  297.          Width           =   735
  298.       End
  299.    End
  300.    Begin MSWinsockLib.Winsock tcpClient 
  301.       Left            =   5640
  302.       Top             =   240
  303.       _ExtentX        =   741
  304.       _ExtentY        =   741
  305.       _Version        =   393216
  306.    End
  307.    Begin VB.Label lblCurCaption 
  308.       BorderStyle     =   1  'Fixed Single
  309.       Caption         =   "Waiting for commmand....."
  310.       Height          =   255
  311.       Left            =   240
  312.       TabIndex        =   8
  313.       Top             =   2400
  314.       Width           =   5685
  315.    End
  316.    Begin VB.Menu mnuFile 
  317.       Caption         =   "&File"
  318.       Begin VB.Menu mnuConnect 
  319.          Caption         =   "&Connect"
  320.       End
  321.       Begin VB.Menu mnuDis 
  322.          Caption         =   "&Disconnect"
  323.       End
  324.       Begin VB.Menu mnuSep2 
  325.          Caption         =   "-"
  326.       End
  327.       Begin VB.Menu mnuAbout 
  328.          Caption         =   "&About"
  329.       End
  330.       Begin VB.Menu mnuSep1 
  331.          Caption         =   "-"
  332.       End
  333.       Begin VB.Menu mnuExit 
  334.          Caption         =   "E&xit"
  335.       End
  336.    End
  337. Attribute VB_Name = "frmCLient"
  338. Attribute VB_GlobalNameSpace = False
  339. Attribute VB_Creatable = False
  340. Attribute VB_PredeclaredId = True
  341. Attribute VB_Exposed = False
  342. Option Explicit
  343. Private WithEvents HostMessages As cClientActions
  344. Attribute HostMessages.VB_VarHelpID = -1
  345. Private ChnkCnt As Long
  346. Private Const About As String = _
  347.     "   This project is a tutorial designed to introduce VB Programmers " _
  348.     & "to an easy method of string transfer using the winsock control between " _
  349.     & "client and server applications. It will enable you to pass a command " _
  350.     & "and as many different strings of info as desired back and forth, then " _
  351.     & "seperate these bits of data into their appropriate destination. I will also " _
  352.     & "demonstrate ONE of many methods of retrieving the file paths of the host computer " _
  353.     & " as well as the host SysInfo." & vbCrLf & vbCrLf _
  354.     & "  This application is totally object oriented." _
  355.     & " All winsock actions are handled from within several class modules. These ""Objects""" _
  356.     & " will give you the basic template for a very effecient Client\Server System."
  357. Private Sub cmdHide_Click()
  358.     Picture1.Visible = False
  359. End Sub
  360. '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  361. '   * E V E N T   P R O C E D U R E S *
  362. '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  363. Private Sub HostMessages_SysInfoArrival()
  364.     ' the sytem Info has been sent in a packaged form
  365.     ' that must be dis-assembled before the proper usage
  366.     ' can be obtained
  367.     ' the output will be displayed on a blank form
  368.     DisplayInfo Client_.Packaged_SysInfo
  369. End Sub
  370. Private Sub HostMessages_TransferDone()
  371.     StatusReport "Transfer Complete."
  372.     Screen.MousePointer = 0
  373.     ' Pause 1 sec
  374.     Pause 1000
  375.     StatusReport "Waiting for command...."
  376.     DoCntrls True
  377.     FileCount True
  378. End Sub
  379. Private Sub HostMessages_ConnMade()
  380.     ' connection made... so unload this form
  381.     Unload frmIP
  382.     DoCntrls True
  383.     mnuConnect.Enabled = False
  384.     StatusReport "Connected to " & Client_.IPAddress
  385. End Sub
  386. Private Sub HostMessages_IncomingDataChunk()
  387.      ' update the list box with the data
  388.      UpdateListBox List1, Client_.FilePath
  389.      ChnkCnt = ChnkCnt + 1
  390.      StatusReport "Recieving Data Chunk #" & ChnkCnt
  391. End Sub
  392. Private Sub HostMessages_DriveInputError()
  393.     Screen.MousePointer = 0
  394.     DoCntrls True
  395.     StatusReport "Waiting for command...."
  396. End Sub
  397. '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  398. ' S U B S
  399. '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  400. Private Sub cmdMsg_Click()
  401.     Client_.SendMsg tcpClient
  402. End Sub
  403. Private Sub cmdSysInfo_Click()
  404.     '
  405.     List1.Clear
  406.     FileCount False
  407.     StatusReport _
  408.     "Retrieving system information on host computer."
  409.     If (Not SendData("SysInfo,")) Then
  410.        tcpClient.Close
  411.     End If
  412. End Sub
  413. Private Sub cmdRetrieve_Click()
  414.     List1.Clear
  415.        
  416.     ' reset the chunk count
  417.     ChnkCnt = 0
  418.     FileCount False
  419.     Client_.NumFiles = 0
  420.     Client_.CurDrive = ""
  421.     DoCntrls False
  422.     Screen.MousePointer = vbHourglass
  423.     Client_.GetUsersFiles tcpClient
  424.     StatusReport "Querying host for file paths on drive " & Left(Client_.CurDrive, 1)
  425. End Sub
  426. Private Sub cmdExit_Click()
  427.     Unload Me
  428. End Sub
  429. Private Sub cmdRetract_Click()
  430.     Me.Height = 3510
  431. End Sub
  432. Private Sub Form_Load()
  433.     bReplied = False
  434.     ' reference the global object, "Client_"
  435.     ' so that when the ConnMade Event is raised it can be
  436.     ' handled privately in this module.
  437.     Set HostMessages = Client_
  438. End Sub
  439. Private Sub Form_Unload(Cancel As Integer)
  440.     ' release objects and the RAM they contain
  441.     Set HostMessages = Nothing
  442.     Set Client_ = Nothing
  443.     End
  444. End Sub
  445. Private Sub mnuConnect_Click()
  446.     frmIP.Show
  447. End Sub
  448. Private Sub mnuDis_Click()
  449.     StatusReport "Connection Closed"
  450.     List1.Clear
  451.     FileCount False
  452.     DoCntrls False
  453.     mnuConnect.Enabled = True
  454.     Client_.DisConnect tcpClient
  455. End Sub
  456. Private Sub mnuAbout_Click()
  457.     '
  458.     ' Expand the form
  459.     '
  460.     Me.Height = 6030
  461.     Text1.FontSize = 10
  462.     Text1 = About
  463. End Sub
  464. Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
  465.   Dim sIncoming As String
  466.   tcpClient.GetData sIncoming
  467.   '--- send the data to be evaluated
  468.   ' if the divider is @ and the command is sysinfo
  469.   ' let eval data know to use a different divide.
  470.   If Client_.EvalData(sIncoming, 1, "@") = "SysInfo" Then
  471.      Client_.HandleIncomingData sIncoming, tcpClient, "@"
  472.   Else
  473.      Client_.HandleIncomingData sIncoming, tcpClient, ","
  474.   End If
  475. End Sub
  476.